[PATCH] D80591: Patch up issues with GN builds (pthread / libz)

Mitch Phillips via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 26 15:17:43 PDT 2020


hctim created this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
hctim updated this revision to Diff 266344.
hctim added a comment.
hctim updated this revision to Diff 266345.
hctim added reviewers: pcc, thakis.

Move dependencies inside the group.


hctim added a comment.

Rebased incorrectly.


Fixes up two small issues with the gn build.

1 - Ensures that the correct ldflag `-pthread` is provided, not just linking the library.
 2 - Ensures that libraries are linked in the same group as the dependencies. This fixes a problem where system libraries (libc) are involved in a link-order dependency that's not being fulfilled.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80591

Files:
  llvm/utils/gn/build/libs/pthread/BUILD.gn
  llvm/utils/gn/build/toolchain/BUILD.gn


Index: llvm/utils/gn/build/toolchain/BUILD.gn
===================================================================
--- llvm/utils/gn/build/toolchain/BUILD.gn
+++ llvm/utils/gn/build/toolchain/BUILD.gn
@@ -88,7 +88,7 @@
       if (current_os == "mac") {
         command = "$ld {{ldflags}} -o $outfile {{libs}} {{inputs}}"
       } else {
-        command = "$ld {{ldflags}} -o $outfile {{libs}} -Wl,--start-group {{inputs}} -Wl,--end-group"
+        command = "$ld {{ldflags}} -o $outfile -Wl,--start-group {{inputs}} {{libs}} -Wl,--end-group"
       }
       description = "LINK $outfile"
       outputs = [ outfile ]
Index: llvm/utils/gn/build/libs/pthread/BUILD.gn
===================================================================
--- llvm/utils/gn/build/libs/pthread/BUILD.gn
+++ llvm/utils/gn/build/libs/pthread/BUILD.gn
@@ -5,9 +5,15 @@
   libs = [ "pthread" ]
 }
 
+config("pthread_link_time_config") {
+  visibility = [ ":pthread" ]
+  ldflags = [ "-pthread" ]
+}
+
 group("pthread") {
   # On Android, bionic has built-in support for pthreads.
   if (llvm_enable_threads && current_os != "win" && current_os != "android") {
     public_configs = [ ":pthread_config" ]
+    all_dependent_configs = [ ":pthread_link_time_config" ]
   }
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80591.266345.patch
Type: text/x-patch
Size: 1247 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200526/e00c6804/attachment.bin>


More information about the llvm-commits mailing list