From 2d4c35fe4028ff0ba3acc8b59b92f7187782f5d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20M=C3=BCller?= Date: Sat, 29 Jan 2022 17:00:42 +0100 Subject: [PATCH] Remove some unnecessary link annotations (#11563) Co-authored-by: Sijawusz Pur Rahnama Co-authored-by: Oleh Prypin --- src/crystal/system/unix/lib_event2.cr | 4 +++- src/gc/boehm.cr | 7 ++++++- src/gc/none.cr | 6 ------ src/math/libm.cr | 5 ++++- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/crystal/system/unix/lib_event2.cr b/src/crystal/system/unix/lib_event2.cr index d6dafcc780f9..5f13c30eb129 100644 --- a/src/crystal/system/unix/lib_event2.cr +++ b/src/crystal/system/unix/lib_event2.cr @@ -1,6 +1,8 @@ require "c/netdb" -{% if flag?(:linux) %} +# MUSL: On musl systems, librt is empty. The entire library is already included in libc. +# The empty library is only available for POSIX compatibility. We don't need to link it. +{% if flag?(:linux) && !flag?(:musl) %} @[Link("rt")] {% end %} diff --git a/src/gc/boehm.cr b/src/gc/boehm.cr index b5b50cf58b70..a5ed138d4151 100644 --- a/src/gc/boehm.cr +++ b/src/gc/boehm.cr @@ -2,7 +2,12 @@ require "crystal/rw_lock" {% end %} -{% unless flag?(:win32) %} +# MUSL: On musl systems, libpthread is empty. The entire library is already included in libc. +# The empty library is only available for POSIX compatibility. We don't need to link it. +# +# OTHERS: On other systems, we add the linker annotation here to make sure libpthread is loaded +# before libgc which looks up symbols from libpthread. +{% unless flag?(:win32) || flag?(:musl) %} @[Link("pthread")] {% end %} diff --git a/src/gc/none.cr b/src/gc/none.cr index 24ed4cb597b1..99ffa9d30b62 100644 --- a/src/gc/none.cr +++ b/src/gc/none.cr @@ -1,9 +1,3 @@ -{% unless flag?(:win32) %} - @[Link("pthread")] - lib LibC - end -{% end %} - module GC def self.init end diff --git a/src/math/libm.cr b/src/math/libm.cr index ec2c71bb621d..a7a7e3f16b91 100644 --- a/src/math/libm.cr +++ b/src/math/libm.cr @@ -1,8 +1,11 @@ +# MUSL: On musl systems, libm is empty. The entire library is already included in libc. +# The empty library is only available for POSIX compatibility. We don't need to link it. +# # Interpreter: On GNU systems, libm.so is typically a GNU ld script which adds # the actual library file to the load path. `Crystal::Loader` does not support # ld scripts yet. So we just skip that for now. The libm symbols are still # available in the interpreter. -{% if (flag?(:linux) && !flag?(:interpreted)) || flag?(:bsd) %} +{% if (flag?(:linux) && !flag?(:musl) && !flag?(:interpreted)) || flag?(:bsd) %} @[Link("m")] {% end %}