27196, "jabraham17", "Problems with multilocale libraries and '--dynamic'", "2025-04-30T22:45:13Z"
While working on some other bug fixes, I found a number of problems with --dynamic
. I attempted to solve them but ended up going too deep down a rabbit hole. This issue captures the various problems I ran into.
On MacOS
runtime/etc/Makefile.mli-shared
is used to build the shared library, but it doesn't seem to work properly on MacOS- It explicitly invokes
ld
instead ofclang
as the linker. But it then passesclang
specific flags like-Wl,-rpath,...
instead of-rpath ...
. This can be fixed by either just usingclang
, or$(shell echo $(CHPL_MAKE_TARGET_SYSTEM_LINK_ARGS) | awk '{while(match($$0, /-Wl,-rpath,/)) {gsub(/-Wl,-rpath,/, "-rpath ")} print}')
as the flags - On MacOS,
ld
by default cannot find standard libraries like-lm
because we need to configure the sysroot. This is something clang handles automatically. For example, on my Mac adding-L/Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/lib
fixed this issue -lm
is passed multiple times, causing warnings- Using
ld
, the proper flag for a shared library on MacOS is-dylib
, not-shared
.clang
automatically translates-shared
to-dylib
- It explicitly invokes
- Even resolving all these build issues, the resulting build hangs on the call to
chpl_library_init
. I specifically testingtest/interop/C/multilocale/use_checkMultipleLocales.ml-test.c
On linux64
CHPL_ZMQ_HOME
does not seem to be respected in all cases. When testingtest/interop/C/multilocale/use_checkMultipleLocales.ml-test.c
, I also had to setCPATH
andLIBRARY_PATH
to get it to compile.- Using
--dynamic
withCHPL_LIB_PIC=none
did not work with confusing errors. I think this is expected, but it would be nice to get better errors.
Testing Issues
- I don't think any of the tests in
test/interop/C/multilocale/
are run in a nightly config. They all require either MacOS (which doesn't run for the below reasons) or CHPL_LIB_PIC=pic (which is none of the tests but python specific ones) test/interop/C/multilocale.skipif
will almost always skip tests, even if zeromq is available. It does not respectCHPL_ZMQ_HOME
, and even on systems where zeromq is in the default path (via pkg-config or some other tool), the test compilation fails. The fix for the skipif is to add--libraries
to thecompileline
command.