Skip to content

Commit

Permalink
Interpreter: Don't link librt and libdl on GNU systems (#12038)
Browse files Browse the repository at this point in the history
  • Loading branch information
1player committed May 16, 2022
1 parent 008438a commit 12de4e1
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 7 deletions.
7 changes: 4 additions & 3 deletions src/crystal/system/unix/lib_event2.cr
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
require "c/netdb"

# 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) %}
# On musl systems, librt is empty. The entire library is already included in libc.
# On gnu systems, it's been integrated into `glibc` since 2.34 and it's not available
# as a shared library.
{% if flag?(:linux) && flag?(:gnu) && !flag?(:interpreted) %}
@[Link("rt")]
{% end %}

Expand Down
5 changes: 4 additions & 1 deletion src/lib_c/aarch64-linux-gnu/c/dlfcn.cr
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
@[Link("dl")]
{% unless flag?(:interpreted) %}
@[Link("dl")]
{% end %}

lib LibC
RTLD_LAZY = 0x00001
RTLD_NOW = 0x00002
Expand Down
5 changes: 4 additions & 1 deletion src/lib_c/arm-linux-gnueabihf/c/dlfcn.cr
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
@[Link("dl")]
{% unless flag?(:interpreted) %}
@[Link("dl")]
{% end %}

lib LibC
RTLD_LAZY = 0x00001
RTLD_NOW = 0x00002
Expand Down
5 changes: 4 additions & 1 deletion src/lib_c/i386-linux-gnu/c/dlfcn.cr
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
@[Link("dl")]
{% unless flag?(:interpreted) %}
@[Link("dl")]
{% end %}

lib LibC
RTLD_LAZY = 0x00001
RTLD_NOW = 0x00002
Expand Down
5 changes: 4 additions & 1 deletion src/lib_c/x86_64-linux-gnu/c/dlfcn.cr
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
@[Link("dl")]
{% unless flag?(:interpreted) %}
@[Link("dl")]
{% end %}

lib LibC
RTLD_LAZY = 0x00001
RTLD_NOW = 0x00002
Expand Down

0 comments on commit 12de4e1

Please sign in to comment.