Skip to content

Commit 1bfcfad

Browse files
committed
[cmake][compiler-rt] Define _DEFAULT_SOURCE instead of enabling extensions
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: #110555
1 parent 0ebcc97 commit 1bfcfad

File tree

5 files changed

+18
-10
lines changed

5 files changed

+18
-10
lines changed

compiler-rt/cmake/Modules/AddCompilerRT.cmake

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@ endmacro()
162162
# OBJECT_LIBS <object libraries to use as sources>
163163
# PARENT_TARGET <convenience parent target>
164164
# ADDITIONAL_HEADERS <header files>
165-
# EXTENSIONS <boolean>
166165
# C_STANDARD <version>
167166
# CXX_STANDARD <version>)
168167
function(add_compiler_rt_runtime name type)
@@ -174,7 +173,7 @@ function(add_compiler_rt_runtime name type)
174173
cmake_parse_arguments(LIB
175174
""
176175
"PARENT_TARGET;C_STANDARD;CXX_STANDARD"
177-
"OS;ARCHS;SOURCES;CFLAGS;LINK_FLAGS;DEFS;DEPS;LINK_LIBS;OBJECT_LIBS;ADDITIONAL_HEADERS;EXTENSIONS"
176+
"OS;ARCHS;SOURCES;CFLAGS;LINK_FLAGS;DEFS;DEPS;LINK_LIBS;OBJECT_LIBS;ADDITIONAL_HEADERS"
178177
${ARGN})
179178
set(libnames)
180179
# Until we support this some other way, build compiler-rt runtime without LTO
@@ -445,10 +444,6 @@ function(add_compiler_rt_runtime name type)
445444
if(type STREQUAL "SHARED")
446445
rt_externalize_debuginfo(${libname})
447446
endif()
448-
449-
if(DEFINED LIB_EXTENSIONS)
450-
set_target_properties(${libname} PROPERTIES C_EXTENSIONS ${LIB_EXTENSIONS})
451-
endif()
452447
endforeach()
453448
if(LIB_PARENT_TARGET)
454449
add_dependencies(${LIB_PARENT_TARGET} ${libnames})

compiler-rt/lib/profile/CMakeLists.txt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,15 +162,13 @@ if(APPLE)
162162
CFLAGS ${EXTRA_FLAGS}
163163
SOURCES ${PROFILE_SOURCES}
164164
ADDITIONAL_HEADERS ${PROFILE_HEADERS}
165-
PARENT_TARGET profile
166-
EXTENSIONS ON)
165+
PARENT_TARGET profile)
167166
else()
168167
add_compiler_rt_runtime(clang_rt.profile
169168
STATIC
170169
ARCHS ${PROFILE_SUPPORTED_ARCH}
171170
CFLAGS ${EXTRA_FLAGS}
172171
SOURCES ${PROFILE_SOURCES}
173172
ADDITIONAL_HEADERS ${PROFILE_HEADERS}
174-
PARENT_TARGET profile
175-
EXTENSIONS ON)
173+
PARENT_TARGET profile)
176174
endif()

compiler-rt/lib/profile/GCDAProfiling.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@
2121

2222
#if !defined(__Fuchsia__)
2323

24+
#if defined(__linux__)
25+
// For fdopen()
26+
#define _DEFAULT_SOURCE
27+
#endif
28+
2429
#include <errno.h>
2530
#include <fcntl.h>
2631
#include <stdint.h>

compiler-rt/lib/profile/InstrProfilingFile.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88

99
#if !defined(__Fuchsia__)
1010

11+
#if defined(__linux__)
12+
// For fileno(), ftruncate(), getpagesize(), setenv()
13+
#define _DEFAULT_SOURCE
14+
#endif
15+
1116
#include <assert.h>
1217
#include <errno.h>
1318
#include <stdio.h>

compiler-rt/lib/profile/InstrProfilingUtil.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@
1212
#include <windows.h>
1313
#include "WindowsMMap.h"
1414
#else
15+
#if defined(__linux__)
16+
// For fdopen(), fileno(), getpagesize(), madvise()
17+
#define _DEFAULT_SOURCE
18+
#endif
19+
1520
#include <errno.h>
1621
#include <fcntl.h>
1722
#include <sys/file.h>

0 commit comments

Comments
 (0)