diff --git a/util/chplenv/chpl_llvm.py b/util/chplenv/chpl_llvm.py index 57d86f586e1e..f78976054a21 100755 --- a/util/chplenv/chpl_llvm.py +++ b/util/chplenv/chpl_llvm.py @@ -630,6 +630,18 @@ def get_host_link_args(): if host_platform == 'darwin': llvm_dynamic = False + shared_mode = run_command([llvm_config, '--shared-mode']) + + if shared_mode.strip() == 'static': + llvm_dynamic = False + + # Make sure to put clang first on the link line + # because depends on LLVM libraries + if llvm_dynamic: + system.append('-lclang-cpp') + else: + system.extend(clang_static_libs) + libdir = run_command([llvm_config, '--libdir']) if libdir: libdir = libdir.strip() @@ -642,10 +654,6 @@ def get_host_link_args(): if ldflags: system.extend(filter_llvm_link_flags(ldflags.split())) - if llvm_dynamic: - system.append('-lclang-cpp') - else: - system.extend(clang_static_libs) elif llvm_val == 'bundled': # Link statically for now for the bundled configuration