[llvm] [OpenMP] Fix not linking C libraries when enabled (PR #109168)

Joseph Huber via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 18 09:56:34 PDT 2024


https://github.com/jhuber6 created https://github.com/llvm/llvm-project/pull/109168

Summary:
We used to do this automatically, add it back in to do it manually.


>From 451382e284e8d3cea184324e235645e9e99df41e Mon Sep 17 00:00:00 2001
From: Joseph Huber <huberjn at outlook.com>
Date: Wed, 18 Sep 2024 11:55:15 -0500
Subject: [PATCH] [OpenMP] Fix not linking C libraries when enabled

Summary:
We used to do this automatically, add it back in to do it manually.
---
 offload/test/lit.cfg | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/offload/test/lit.cfg b/offload/test/lit.cfg
index 9ddef42cf90370..514bb89e0b644e 100644
--- a/offload/test/lit.cfg
+++ b/offload/test/lit.cfg
@@ -182,7 +182,12 @@ def remove_suffix_if_present(name):
         return name
 
 def add_libraries(source):
-    return source + " " + config.llvm_library_intdir + "/libomptarget.devicertl.a"
+    if config.libomptarget_has_libc:
+        return source + " -Xoffload-linker " + "-lc " + \
+               "-Xoffload-linker " + "-lm " + \
+               config.llvm_library_intdir + "/libomptarget.devicertl.a"
+    else:
+        return source + " " + config.llvm_library_intdir + "/libomptarget.devicertl.a"
 
 # Add platform targets
 host_targets = [



More information about the llvm-commits mailing list