From 765dde6bd4138af77f28ea3fe5a1c25473bb5634 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Fri, 18 Feb 2022 10:31:22 -0500 Subject: [PATCH] Fix problem with static link order with static clang and llvm --- Signed-off-by: Michael Ferguson --- util/chplenv/chpl_llvm.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) 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