Skip to content

Commit b6a1e63

Browse files
committed
configure: fix compilation on recent macOS Xcode versions
Back in ccf2d89 ("configure: try to disable weak linking on OSX") disabling weak symbols was done to prevent depending on features when building on a newer macOS but targeting an older one. Fast-forward to Xcode 11.4 and it turns out Apple have broken this by depending on weak symbols for critical symbols like FD_SET leading to compilation errors like the following ld: weak import of symbol '___darwin_check_fd_set_overflow' not supported because of option: -no_weak_imports for architecture x86_64 Other people/projects have been hit by this issue: - https://openradar.appspot.com/FB7647406 - mono/mono#19393 but Apple have kept this behaviour into XCode 12 so we should adapt. - Introduce the concept of configure only CFLAGS - Switch to using -Werror=partial-availability with the above - Stop logging a message about disabling weak linking The above should avoid finding features the target platform doesn't have while allowing weak linking. The name CONFIGURE_CFLAGS is used to remain similar to QEMU's configure. Fingers crossed this approach stays supported by Apple... Fixes axboe#1006 Signed-off-by: Sitsofe Wheeler <sitsofe@yahoo.com>
1 parent ced2246 commit b6a1e63

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

configure

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ print_config() {
4545

4646
# Default CFLAGS
4747
CFLAGS="-D_GNU_SOURCE -include config-host.h $CFLAGS"
48+
CONFIGURE_CFLAGS="-Werror-implicit-function-declaration"
4849
BUILD_CFLAGS=""
4950

5051
# Print a helpful header at the top of config.log
@@ -88,14 +89,14 @@ do_cc() {
8889
}
8990

9091
compile_object() {
91-
do_cc $CFLAGS -Werror-implicit-function-declaration -c -o $TMPO $TMPC
92+
do_cc $CFLAGS $CONFIGURE_CFLAGS -c -o $TMPO $TMPC
9293
}
9394

9495
compile_prog() {
9596
local_cflags="$1"
9697
local_ldflags="$2 $LIBS"
9798
echo "Compiling test case $3" >> config.log
98-
do_cc $CFLAGS -Werror-implicit-function-declaration $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags
99+
do_cc $CFLAGS $CONFIGURE_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags
99100
}
100101

101102
feature_not_found() {
@@ -360,16 +361,15 @@ Darwin)
360361
if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
361362
cpu="x86_64"
362363
fi
363-
# Error at compile time linking of weak/partial symbols if possible...
364+
# Avoid configure feature detection of features provided by weak symbols
364365
cat > $TMPC <<EOF
365366
int main(void)
366367
{
367368
return 0;
368369
}
369370
EOF
370-
if compile_prog "" "-Wl,-no_weak_imports" "disable weak symbols"; then
371-
echo "Disabling weak symbols"
372-
LDFLAGS="$LDFLAGS -Wl,-no_weak_imports"
371+
if compile_prog "" "-Werror=partial-availability" "error on weak symbols"; then
372+
CONFIGURE_CFLAGS="$CONFIGURE_CFLAGS -Werror=partial-availability"
373373
fi
374374
;;
375375
SunOS)

0 commit comments

Comments
 (0)