Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cc's search paths to Unix dynamic library loader #15127

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions spec/std/llvm/aarch64_spec.cr
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
require "spec"

{% if flag?(:interpreted) && !flag?(:win32) %}
# TODO: figure out how to link against libstdc++ in interpreted code (#14398)
pending LLVM::ABI::AArch64
{% skip_file %}
{% end %}

require "llvm"

{% if LibLLVM::BUILT_TARGETS.includes?(:aarch64) %}
Expand Down
7 changes: 0 additions & 7 deletions spec/std/llvm/arm_abi_spec.cr
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
require "spec"

{% if flag?(:interpreted) && !flag?(:win32) %}
# TODO: figure out how to link against libstdc++ in interpreted code (#14398)
pending LLVM::ABI::ARM
{% skip_file %}
{% end %}

require "llvm"

{% if LibLLVM::BUILT_TARGETS.includes?(:arm) %}
Expand Down
7 changes: 0 additions & 7 deletions spec/std/llvm/avr_spec.cr
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
require "spec"

{% if flag?(:interpreted) && !flag?(:win32) %}
# TODO: figure out how to link against libstdc++ in interpreted code (#14398)
pending LLVM::ABI::AVR
{% skip_file %}
{% end %}

require "llvm"

{% if LibLLVM::BUILT_TARGETS.includes?(:avr) %}
Expand Down
7 changes: 0 additions & 7 deletions spec/std/llvm/llvm_spec.cr
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
require "spec"

{% if flag?(:interpreted) && !flag?(:win32) %}
# TODO: figure out how to link against libstdc++ in interpreted code (#14398)
pending LLVM
{% skip_file %}
{% end %}

require "llvm"

describe LLVM do
Expand Down
7 changes: 0 additions & 7 deletions spec/std/llvm/type_spec.cr
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
require "spec"

{% if flag?(:interpreted) && !flag?(:win32) %}
# TODO: figure out how to link against libstdc++ in interpreted code (#14398)
pending LLVM::Type
{% skip_file %}
{% end %}

require "llvm"

describe LLVM::Type do
Expand Down
7 changes: 0 additions & 7 deletions spec/std/llvm/x86_64_abi_spec.cr
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
require "spec"

{% if flag?(:interpreted) && !flag?(:win32) %}
# TODO: figure out how to link against libstdc++ in interpreted code (#14398)
pending LLVM::ABI::X86_64
{% skip_file %}
{% end %}

require "llvm"

{% if LibLLVM::BUILT_TARGETS.includes?(:x86) %}
Expand Down
7 changes: 0 additions & 7 deletions spec/std/llvm/x86_abi_spec.cr
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
{% skip_file if flag?(:win32) %} # 32-bit windows is not supported

require "spec"

{% if flag?(:interpreted) %}
# TODO: figure out how to link against libstdc++ in interpreted code (#14398)
pending LLVM::ABI::X86
{% skip_file %}
{% end %}

require "llvm"

{% if LibLLVM::BUILT_TARGETS.includes?(:x86) %}
Expand Down
22 changes: 21 additions & 1 deletion src/compiler/crystal/loader/unix.cr
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ class Crystal::Loader
read_ld_conf(default_search_paths)
{% end %}

cc_each_library_path do |path|
default_search_paths << path
end

{% if flag?(:darwin) %}
default_search_paths << "/usr/lib"
default_search_paths << "/usr/local/lib"
Expand All @@ -179,7 +183,7 @@ class Crystal::Loader
default_search_paths << "/usr/lib"
{% end %}

default_search_paths
default_search_paths.uniq!
end

def self.read_ld_conf(array = [] of String, path = "/etc/ld.so.conf") : Nil
Expand All @@ -201,4 +205,20 @@ class Crystal::Loader
end
end
end

def self.cc_each_library_path(& : String ->) : Nil
search_dirs = begin
`#{Crystal::Compiler::DEFAULT_LINKER} -print-search-dirs`
rescue IO::Error
return
end

search_dirs.each_line do |line|
if libraries = line.lchop?("libraries: =")
libraries.split(Process::PATH_DELIMITER) do |path|
yield File.expand_path(path)
end
end
end
end
end
Loading