-
Notifications
You must be signed in to change notification settings - Fork 15k
[cmake][compiler-rt] Define _DEFAULT_SOURCE instead of enabling extensions #163377
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
0eac16e to
2bb42d3
Compare
|
@llvm/pr-subscribers-pgo Author: Raul Tambre (tambry) ChangesGNU extensions are a bit of a hammer approach to enabling access to POSIX extensions. Instead we can define _DEFAULT_SOURCE ourselves, which is what the extensions mechanism does. See: #110555 Full diff: https://github.com/llvm/llvm-project/pull/163377.diff 2 Files Affected:
diff --git a/compiler-rt/cmake/Modules/AddCompilerRT.cmake b/compiler-rt/cmake/Modules/AddCompilerRT.cmake
index fb2aee8e42ee2..d658b7009e859 100644
--- a/compiler-rt/cmake/Modules/AddCompilerRT.cmake
+++ b/compiler-rt/cmake/Modules/AddCompilerRT.cmake
@@ -162,7 +162,6 @@ endmacro()
# OBJECT_LIBS <object libraries to use as sources>
# PARENT_TARGET <convenience parent target>
# ADDITIONAL_HEADERS <header files>
-# EXTENSIONS <boolean>
# C_STANDARD <version>
# CXX_STANDARD <version>)
function(add_compiler_rt_runtime name type)
@@ -174,7 +173,7 @@ function(add_compiler_rt_runtime name type)
cmake_parse_arguments(LIB
""
"PARENT_TARGET;C_STANDARD;CXX_STANDARD"
- "OS;ARCHS;SOURCES;CFLAGS;LINK_FLAGS;DEFS;DEPS;LINK_LIBS;OBJECT_LIBS;ADDITIONAL_HEADERS;EXTENSIONS"
+ "OS;ARCHS;SOURCES;CFLAGS;LINK_FLAGS;DEFS;DEPS;LINK_LIBS;OBJECT_LIBS;ADDITIONAL_HEADERS"
${ARGN})
set(libnames)
# Until we support this some other way, build compiler-rt runtime without LTO
@@ -445,10 +444,6 @@ function(add_compiler_rt_runtime name type)
if(type STREQUAL "SHARED")
rt_externalize_debuginfo(${libname})
endif()
-
- if(DEFINED LIB_EXTENSIONS)
- set_target_properties(${libname} PROPERTIES C_EXTENSIONS ${LIB_EXTENSIONS})
- endif()
endforeach()
if(LIB_PARENT_TARGET)
add_dependencies(${LIB_PARENT_TARGET} ${libnames})
diff --git a/compiler-rt/lib/profile/CMakeLists.txt b/compiler-rt/lib/profile/CMakeLists.txt
index ac1451c8ceed1..4753bdb35e003 100644
--- a/compiler-rt/lib/profile/CMakeLists.txt
+++ b/compiler-rt/lib/profile/CMakeLists.txt
@@ -135,6 +135,10 @@ if(COMPILER_RT_TARGET_HAS_UNAME)
-DCOMPILER_RT_HAS_UNAME=1)
endif()
+if(OS_NAME MATCHES "Linux")
+ list(APPEND EXTRA_FLAGS "-D_DEFAULT_SOURCE")
+endif()
+
if(MSVC)
# profile historically has only been supported with the static runtime
# on windows
@@ -162,8 +166,7 @@ if(APPLE)
CFLAGS ${EXTRA_FLAGS}
SOURCES ${PROFILE_SOURCES}
ADDITIONAL_HEADERS ${PROFILE_HEADERS}
- PARENT_TARGET profile
- EXTENSIONS ON)
+ PARENT_TARGET profile)
else()
add_compiler_rt_runtime(clang_rt.profile
STATIC
@@ -171,6 +174,5 @@ else()
CFLAGS ${EXTRA_FLAGS}
SOURCES ${PROFILE_SOURCES}
ADDITIONAL_HEADERS ${PROFILE_HEADERS}
- PARENT_TARGET profile
- EXTENSIONS ON)
+ PARENT_TARGET profile)
endif()
|
|
Can you add to the commit message/PR description, what parts of the code needs this to be defined? |
2bb42d3 to
0b35bc1
Compare
…sions GNU extensions are a bit of a hammer approach to enabling access to POSIX extensions. Instead we can define _DEFAULT_SOURCE ourselves where necessary, which is what the extensions mechanism does. See: llvm#110555
0b35bc1 to
1bfcfad
Compare
|
@mstorsjo Changed over to explicit defines in the applicable files with comments for the functions its needed for. |
This looks great, thanks! Are we sure that this is only needed on |
|
@mstorsjo As far as I can tell |
Ok, fair enough. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/186/builds/13348 Here is the relevant piece of the build log for the reference |
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/76/builds/13263 Here is the relevant piece of the build log for the reference |
…sions (llvm#163377) GNU extensions are a bit of a hammer approach to enabling access to POSIX extensions. Instead we can define _DEFAULT_SOURCE ourselves where necessary, which is what the extensions mechanism does. See: llvm#110555
…sions (llvm#163377) GNU extensions are a bit of a hammer approach to enabling access to POSIX extensions. Instead we can define _DEFAULT_SOURCE ourselves where necessary, which is what the extensions mechanism does. See: llvm#110555
GNU extensions are a bit of a hammer approach to enabling access to POSIX extensions. Instead we can define _DEFAULT_SOURCE ourselves, which is what the extensions mechanism does.
See: #110555