summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Neben <alexander.neben@mongodb.com>2022-10-12 14:14:42 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-10-12 15:38:56 +0000
commit36194c546281d6a10b003bf3cd12f771ff268c50 (patch)
treefa6d055783419e3ec1e03448505f4524373c6506
parent8461ed030674d503d259129fbf88a3ee0711fde9 (diff)
downloadmongo-36194c546281d6a10b003bf3cd12f771ff268c50.tar.gz
SERVER-69196 don't build dwarf on gcc4
-rw-r--r--SConstruct45
-rw-r--r--etc/scons/mongodbtoolchain_v3_clang.vars3
-rw-r--r--etc/scons/mongodbtoolchain_v3_gcc.vars3
-rw-r--r--etc/scons/mongodbtoolchain_v4_clang.vars3
-rw-r--r--etc/scons/mongodbtoolchain_v4_gcc.vars2
5 files changed, 51 insertions, 5 deletions
diff --git a/SConstruct b/SConstruct
index 815d6bc8844..dead2c01084 100644
--- a/SConstruct
+++ b/SConstruct
@@ -1028,6 +1028,22 @@ env_vars.Add(
help='Path to the dsymutil utility',
)
+
+def validate_dwarf_version(key, val, env):
+ if val == '4' or val == '5':
+ return
+
+ print(f"Invalid DWARF_VERSION '{val}'. Only valid versions are 4 or 5.")
+ Exit(1)
+
+
+env_vars.Add(
+ 'DWARF_VERSION',
+ help='Sets the DWARF version (non-Windows). Incompatible with SPLIT_DWARF=1.',
+ validator=validate_dwarf_version,
+ converter=int,
+)
+
env_vars.Add(
'GITDIFFFLAGS',
help='Sets flags for git diff',
@@ -1330,8 +1346,11 @@ env_vars.Add(
env_vars.Add(
'SPLIT_DWARF',
- help='Set the boolean (auto, on/off true/false 1/0) to enable gsplit-dwarf (non-Windows).',
- converter=split_dwarf_converter, default="auto")
+ help=
+ 'Set the boolean (auto, on/off true/false 1/0) to enable gsplit-dwarf (non-Windows). Incompatible with DWARF_VERSION=5',
+ converter=split_dwarf_converter,
+ default="auto",
+)
env_vars.Add(
'TAPI',
@@ -2817,6 +2836,14 @@ if env.TargetOSIs('posix'):
"-Winvalid-pch",
], )
+ if env.get('DWARF_VERSION'):
+ if env.TargetOSIs('darwin'):
+ env.FatalError("Setting DWARF_VERSION on darwin is not supported.")
+ env.AppendUnique(
+ CCFLAGS=['-gdwarf-$DWARF_VERSION'],
+ LINKFLAGS=['-gdwarf-$DWARF_VERSION'],
+ )
+
# TODO: At least on x86, glibc as of 2.3.4 will consult the
# .eh_frame info via _Unwind_Backtrace to do backtracing without
# needing the frame pointer, despite what the backtrace man page
@@ -5547,11 +5574,19 @@ if env['SPLIT_DWARF'] == "auto":
# For static builds, splitting out the dwarf info reduces memory requirments, link time
# and binary size significantly. It's affect is less prominent in dynamic builds. The downside
# is .dwo files use absolute paths in the debug info, so it's not relocatable.
- env['SPLIT_DWARF'] = (not link_model == "dynamic" and env.ToolchainIs('gcc', 'clang')
- and not env.TargetOSIs('darwin')
- and env.CheckCCFLAGSSupported('-gsplit-dwarf'))
+ # We also found the running splitdwarf with dwarf5 failed to compile
+ # so unless we set DWARF_VERSION = 4 we are going to turn off split dwarf
+ env['SPLIT_DWARF'] = (not link_model == "dynamic" and not env.TargetOSIs('darwin')
+ and env.CheckCCFLAGSSupported('-gsplit-dwarf')
+ and env.get('DWARF_VERSION') == 4)
if env['SPLIT_DWARF']:
+ if env.TargetOSIs('darwin'):
+ env.FatalError("Setting SPLIT_DWARF=1 on darwin is not supported.")
+ if env.get('DWARF_VERSION') != 4:
+ env.FatalError(
+ 'Running split dwarf outside of DWARF4 has shown compilation issues when using DWARF5 and gdb index. Disabling this functionality for now. Use SPLIT_DWARF=0 to disable building with split dwarf or use DWARF_VERSION=4 to pin to DWARF version 4.'
+ )
if env.ToolchainIs('gcc', 'clang'):
env.AddToLINKFLAGSIfSupported('-Wl,--gdb-index')
env.Tool('split_dwarf')
diff --git a/etc/scons/mongodbtoolchain_v3_clang.vars b/etc/scons/mongodbtoolchain_v3_clang.vars
index 3a73894628e..ab66f1f2489 100644
--- a/etc/scons/mongodbtoolchain_v3_clang.vars
+++ b/etc/scons/mongodbtoolchain_v3_clang.vars
@@ -40,3 +40,6 @@ except subprocess.CalledProcessError as e:
except OSError as e:
print("Failed to invoke toolchain binary " + CXX + ": " + str(e))
SCons.Script.Exit(-1)
+
+
+DWARF_VERSION=4
diff --git a/etc/scons/mongodbtoolchain_v3_gcc.vars b/etc/scons/mongodbtoolchain_v3_gcc.vars
index 48809aa8acd..e9ccbe0f92b 100644
--- a/etc/scons/mongodbtoolchain_v3_gcc.vars
+++ b/etc/scons/mongodbtoolchain_v3_gcc.vars
@@ -39,3 +39,6 @@ except subprocess.CalledProcessError as e:
except OSError as e:
print('Failed to invoke toolchain binary ' + CXX + ': ' + str(e))
SCons.Script.Exit(-1)
+
+
+DWARF_VERSION=4
diff --git a/etc/scons/mongodbtoolchain_v4_clang.vars b/etc/scons/mongodbtoolchain_v4_clang.vars
index 693470ca0e6..ab1b6ddcba2 100644
--- a/etc/scons/mongodbtoolchain_v4_clang.vars
+++ b/etc/scons/mongodbtoolchain_v4_clang.vars
@@ -40,3 +40,6 @@ except subprocess.CalledProcessError as e:
except OSError as e:
print("Failed to invoke toolchain binary " + CXX + ": " + str(e))
SCons.Script.Exit(-1)
+
+
+DWARF_VERSION=4
diff --git a/etc/scons/mongodbtoolchain_v4_gcc.vars b/etc/scons/mongodbtoolchain_v4_gcc.vars
index 888e40321d3..ee18f0d9427 100644
--- a/etc/scons/mongodbtoolchain_v4_gcc.vars
+++ b/etc/scons/mongodbtoolchain_v4_gcc.vars
@@ -39,3 +39,5 @@ except subprocess.CalledProcessError as e:
except OSError as e:
print('Failed to invoke toolchain binary ' + CXX + ': ' + str(e))
SCons.Script.Exit(-1)
+
+DWARF_VERSION=5