New Issue: Problems with multilocale libraries and '--dynamic'

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 of clang as the linker. But it then passes clang specific flags like -Wl,-rpath,... instead of -rpath .... This can be fixed by either just using clang, 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
  • Even resolving all these build issues, the resulting build hangs on the call to chpl_library_init. I specifically testing test/interop/C/multilocale/use_checkMultipleLocales.ml-test.c

On linux64

  • CHPL_ZMQ_HOME does not seem to be respected in all cases. When testing test/interop/C/multilocale/use_checkMultipleLocales.ml-test.c, I also had to set CPATH and LIBRARY_PATH to get it to compile.
  • Using --dynamic with CHPL_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 respect CHPL_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 the compileline command.