weak import __darwin_check_fd_set_overflow breaks -no_weak_imports linker option

Originator:lewurm
Number:rdar://FB7647406 Date Originated:04/01/2020
Status:Open Resolved:
Product:Xcode Product Version:Xcode 11.4 (11E146)
Classification:Incorrect/Unexpected Behavior Reproducible:yes
 
Please describe the issue:
The newly added weak import of `__darwin_check_fd_set_overflow` in `usr/include/sys/_types/_fd_def.h` breaks the `-no_weak_imports` linker option.


Please list the steps you took to reproduce the issue:
see https://gist.github.com/lewurm/210b320cb6037ca8ad4a370adf1bde11

Copy/paste here:


$ make set_xcode11.3
sudo xcode-select -s /Applications/Xcode113.app/Contents/Developer
$ xcodebuild -version
Xcode 11.3
Build version 11C29

$ cat c.c
#include <sys/select.h>

int foo (void) {
        fd_set s;
        FD_SET (0, &s);
        return FD_ISSET (0, &s);
}

$ make c.dylib
clang -c -mmacosx-version-min=10.9 -o c.o c.c
clang -dynamiclib -mmacosx-version-min=10.9 -Wl,-no_weak_imports -o c.dylib c.o
$ nm c.o
0000000000000060 t ___darwin_fd_isset
0000000000000000 T _foo
$ make clean
rm -f c.dylib c.o

$ make set_xcode11.4
sudo xcode-select -s /Applications/Xcode114.app/Contents/Developer
$ xcodebuild -version
Xcode 11.4
Build version 11E146

$ make c.dylib
clang -c -mmacosx-version-min=10.9 -o c.o c.c
clang -dynamiclib -mmacosx-version-min=10.9 -Wl,-no_weak_imports -o c.dylib c.o
ld: weak import of symbol '___darwin_check_fd_set_overflow' not supported because of option: -no_weak_imports for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [c.dylib] Error 1
$ nm c.o
                 U ___darwin_check_fd_set_overflow
0000000000000000 T _foo


What did you expect to happen?
Behave as Xcode 11.3 and successfully link.


What actually happened?
Linking fails due to weak import of `__darwin_check_fd_set_overflow`.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!