Skip to content

Commit

Permalink
Prepare for updated toolchains (#211)
Browse files Browse the repository at this point in the history
* provide -rpath-link by default

This fixes the link with depended upon libraries, which are not found
when this flag is lacking and the libraries are not explicitely
provided.
This is basically the equivalent of `-L` for libraries that are listed
in the `DT_NEEDED` section of a library boing linked with.
This is fixing some issues with (at least) curl & gcrypt, but I
introduced this before trying to build other dependencies so there are
likely more.
If I'm being honest I don't understand why this wasn't required before,
I'm guessing some change in libtool, but I wasn't able to identify
something precisely.

* allow environment to override compiler & cmake toolchain

* simplify environment variables forwarding

* keep rubocop happy

* use symbols instead of strings

* fix env forwarding
  • Loading branch information
chouquette authored Sep 27, 2024
1 parent db96ee7 commit 1c20696
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
6 changes: 5 additions & 1 deletion lib/omnibus/builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,13 @@ def cmake(*args)
cmake_cmd << "-DCMAKE_INSTALL_LIBDIR=#{libdir}" if libdir && libdir != ""
rpath = options.delete(:rpath) || "#{prefix}/#{libdir}"
cmake_cmd << "-DCMAKE_INSTALL_RPATH=#{rpath}" if rpath && rpath != ""

if ENV['DD_CMAKE_TOOLCHAIN']
cmake_cmd << "--toolchain #{ENV['DD_CMAKE_TOOLCHAIN']}"
end

cmake_cmd.concat args
cmake_cmd = cmake_cmd.join(" ").strip

command(cmake_cmd, options)

make("-j #{workers}", options)
Expand Down
20 changes: 18 additions & 2 deletions lib/omnibus/software.rb
Original file line number Diff line number Diff line change
Expand Up @@ -785,11 +785,27 @@ def with_standard_compiler_flags(env = {}, opts = {})
"CFLAGS" => "-I#{install_dir}/embedded/include #{arch_flag} -O2 -fno-lto #{opt_flag}",
}
else
{
flags = {
# -z origin makes the rpath interpret the $ORIGIN variable as the binary path
"LDFLAGS" => "-Wl,-rpath,#{install_dir}/embedded/lib,-z,origin -L#{install_dir}/embedded/lib",
"LDFLAGS" => "-Wl,-rpath,#{install_dir}/embedded/lib,-z,origin -L#{install_dir}/embedded/lib -Wl,-rpath-link=#{install_dir}/embedded/lib",
"CFLAGS" => "-I#{install_dir}/embedded/include -O2",
}
# List of environment variables to forward and potentially map to an alternate name
# If the value is nil, the key will simply be forwarded from ENV to flags
to_forward = {
DD_CC: "CC",
DD_CXX: "CXX",
DD_CMAKE_TOOLCHAIN: nil,
}
to_forward.each do |orig, forwarded|
if ENV[orig.to_s]
flags[forwarded] = ENV[orig.to_s] if forwarded
# Forward the toolchain env since some invoke tasks
# rely on it down the line
flags[orig.to_s] = ENV[orig.to_s]
end
end
flags
end

# merge LD_RUN_PATH into the environment. most unix distros will fall
Expand Down

0 comments on commit 1c20696

Please sign in to comment.