@@ -59,7 +59,7 @@ object ConfigurationPresets {
5959 project.logger.lifecycle(" Active configurations: ${activeConfigs.map { it.name }.joinToString(" , " )} " )
6060 }
6161
62- private fun commonLinuxCompilerArgs (version : String ): List <String > {
62+ private fun commonCompilerArgs (version : String ): List <String > {
6363 val args = mutableListOf (
6464 " -fPIC" ,
6565 " -fno-omit-frame-pointer" ,
@@ -78,6 +78,19 @@ object ConfigurationPresets {
7878 return args
7979 }
8080
81+ private fun commonLinuxCompilerArgs (
82+ version : String ,
83+ architecture : Architecture = Architecture .X64
84+ ): List <String > {
85+ val args = commonCompilerArgs(version).toMutableList()
86+ // Use TLS descriptors (GNU2 dialect) for thread-local storage on x86_64.
87+ // This is required by thread context (https://github.com/open-telemetry/opentelemetry-specification/pull/4947)
88+ if (architecture == Architecture .X64 ) {
89+ args.add(" -mtls-dialect=gnu2" )
90+ }
91+ return args
92+ }
93+
8194 private fun commonLinuxLinkerArgs (): List <String > = listOf (
8295 " -ldl" ,
8396 " -Wl,-z,defs" ,
@@ -89,7 +102,7 @@ object ConfigurationPresets {
89102 )
90103
91104 private fun commonMacosCompilerArgs (version : String ): List <String > =
92- commonLinuxCompilerArgs (version) + listOf (" -D_XOPEN_SOURCE" , " -D_DARWIN_C_SOURCE" )
105+ commonCompilerArgs (version) + listOf (" -D_XOPEN_SOURCE" , " -D_DARWIN_C_SOURCE" )
93106
94107 fun configureRelease (
95108 config : BuildConfiguration ,
@@ -104,7 +117,7 @@ object ConfigurationPresets {
104117 when (platform) {
105118 Platform .LINUX -> {
106119 config.compilerArgs.set(
107- listOf (" -O3" , " -DNDEBUG" , " -g" ) + commonLinuxCompilerArgs(version)
120+ listOf (" -O3" , " -DNDEBUG" , " -g" ) + commonLinuxCompilerArgs(version, architecture )
108121 )
109122 config.linkerArgs.set(
110123 commonLinuxLinkerArgs() + listOf (
@@ -138,7 +151,7 @@ object ConfigurationPresets {
138151 when (platform) {
139152 Platform .LINUX -> {
140153 config.compilerArgs.set(
141- listOf (" -O0" , " -g" , " -DDEBUG" ) + commonLinuxCompilerArgs(version)
154+ listOf (" -O0" , " -g" , " -DDEBUG" ) + commonLinuxCompilerArgs(version, architecture )
142155 )
143156 config.linkerArgs.set(commonLinuxLinkerArgs())
144157 }
@@ -184,7 +197,7 @@ object ConfigurationPresets {
184197
185198 when (platform) {
186199 Platform .LINUX -> {
187- config.compilerArgs.set(asanCompilerArgs + commonLinuxCompilerArgs(version))
200+ config.compilerArgs.set(asanCompilerArgs + commonLinuxCompilerArgs(version, architecture ))
188201
189202 val libasan = PlatformUtils .locateLibasan(compiler)
190203 // Link against the sanitizer runtime that matches the compiler:
@@ -247,7 +260,7 @@ object ConfigurationPresets {
247260
248261 when (platform) {
249262 Platform .LINUX -> {
250- config.compilerArgs.set(tsanCompilerArgs + commonLinuxCompilerArgs(version))
263+ config.compilerArgs.set(tsanCompilerArgs + commonLinuxCompilerArgs(version, architecture ))
251264
252265 val libtsan = PlatformUtils .locateLibtsan(compiler)
253266 // Use the library name from the resolved path so that clang's own
@@ -321,7 +334,7 @@ object ConfigurationPresets {
321334
322335 when (platform) {
323336 Platform .LINUX -> {
324- config.compilerArgs.set(fuzzerCompilerArgs + commonLinuxCompilerArgs(version))
337+ config.compilerArgs.set(fuzzerCompilerArgs + commonLinuxCompilerArgs(version, architecture ))
325338 config.linkerArgs.set(commonLinuxLinkerArgs() + fuzzerLinkerArgs)
326339
327340 config.testEnvironment.apply {
0 commit comments