Created
September 21, 2023 12:26
-
-
Save fxcoudert/7127b8f92223dd2131f191b8b5f6e549 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Trying to compile open-mpi on macOS Sonoma with Xcode 15 (or CLT 15) Release Candidate fails, because the new linker has a behaviour inconsistent with the previous (classic) linker. The error occurs during configure: | |
checking prefix for global symbol labels... none | |
configure: error: Could not determine global symbol label prefix | |
I have been able to reduce it to a simple example. Take the following C and ASM files: | |
$ cat a.c | |
#ifdef __cplusplus | |
extern "C" { | |
#endif | |
void gsym_test_func(void); | |
#ifdef __cplusplus | |
} | |
#endif | |
int | |
main() | |
{ | |
gsym_test_func(); | |
return 0; | |
} | |
$ cat b.s | |
.text | |
# _gsym_test_func | |
.globl _gsym_test_func | |
_gsym_test_func: | |
# _gsym_test_func | |
fx@admins-Mac-mini openmpi-4.1.5 % clang a.c b.s -Wl,-ld_classic | |
fx@admins-Mac-mini openmpi-4.1.5 % clang a.c b.s | |
ld: Undefined symbols: | |
_gsym_test_func, referenced from: | |
_main in a-822851.o | |
clang: error: linker command failed with exit code 1 (use -v to see invocation) | |
Compile them with the classic linker, it works: | |
$ clang a.c b.s -Wl,-ld_classic | |
Compile them with the new linker, it fails: | |
$ clang a.c b.s | |
ld: Undefined symbols: | |
_gsym_test_func, referenced from: | |
_main in a-92d1f8.o | |
clang: error: linker command failed with exit code 1 (use -v to see invocation) | |
I am not sure why, because the symbols are clearly defined in the object files: | |
$ clang a.c b.s -save-temps | |
ld: Undefined symbols: | |
_gsym_test_func, referenced from: | |
_main in a.o | |
clang: error: linker command failed with exit code 1 (use -v to see invocation) | |
$ nm a.o | |
U _gsym_test_func | |
0000000000000000 T _main | |
0000000000000000 t ltmp0 | |
0000000000000030 s ltmp1 | |
$ nm b.o | |
0000000000000000 T _gsym_test_func | |
0000000000000000 t ltmp0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment