Skip to content

Commit

Permalink
Added initial gcc deps for solaris 10
Browse files Browse the repository at this point in the history
Allow solaris to use mapfiles

This change allows the optional use of a Solaris 10 linker mapfile.
It also updates the whitelist for Solaris 10 library healthcheck to
enable libraries that are 10+.

This also has 1 breaking change. solaris_compiler has been removed.
  • Loading branch information
scotthain committed Feb 26, 2015
1 parent 4c4ff73 commit 7be82bc
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 10 deletions.
10 changes: 8 additions & 2 deletions lib/omnibus/config.rb
Expand Up @@ -432,10 +432,16 @@ def reset!
['omnibus-software']
end

# The solaris compiler to use
# Solaris linker mapfile to use, if needed
# see http://docs.oracle.com/cd/E23824_01/html/819-0690/chapter5-1.html
# Path is relative to the 'files' directory in your omnibus project
#
# For example:
#
# /PATH/files/my_map_file
#
# @return [String, nil]
default(:solaris_compiler, nil)
default(:solaris_linker_mapfile, "files/mapfiles/solaris")

# --------------------------------------------------
# @!endgroup
Expand Down
2 changes: 2 additions & 0 deletions lib/omnibus/health_check.rb
Expand Up @@ -72,12 +72,14 @@ class HealthCheck
/libmd5\.so/,
/libmd\.so/,
/libmp\.so/,
/libresolv\.so/,
/libscf\.so/,
/libsec\.so/,
/libsocket\.so/,
/libssl.so/,
/libthread.so/,
/libuutil\.so/,
/libkstat\.so/,
# solaris 11 libraries:
/libc\.so\.1/,
/libm\.so\.2/,
Expand Down
28 changes: 21 additions & 7 deletions lib/omnibus/software.rb
Expand Up @@ -499,13 +499,27 @@ def with_standard_compiler_flags(env = {}, opts = {})
extra_linker_flags = {
"LD_RUN_PATH" => "#{install_dir}/embedded/lib"
}
# solaris linker can also use LD_OPTIONS, so we throw the kitchen sink against
# the linker, to find every way to make it use our rpath.
extra_linker_flags.merge!(
{
"LD_OPTIONS" => "-R#{install_dir}/embedded/lib"
}
) if Ohai['platform'] == "solaris2"

if solaris2?
# in order to provide compatibility for earlier versions of libc on solaris 10,
# we need to specify a mapfile that restricts the version of system libraries
# used. See http://docs.oracle.com/cd/E23824_01/html/819-0690/chapter5-1.html
# for more information
# use the mapfile if it exists, otherwise ignore it
ld_options = "-R#{install_dir}/embedded/lib"
mapfile_path = File.expand_path(Config.solaris_linker_mapfile, Config.project_root)
ld_options << " -M #{mapfile_path}" if File.exist?(mapfile_path)

# solaris linker can also use LD_OPTIONS, so we throw the kitchen sink against
# the linker, to find every way to make it use our rpath. This is also required
# to use the aforementioned mapfile.
extra_linker_flags.merge!(
{
"LD_OPTIONS" => ld_options
}
)
end

env.merge(compiler_flags).
merge(extra_linker_flags).
# always want to favor pkg-config from embedded location to not hose
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/config_spec.rb
Expand Up @@ -37,7 +37,7 @@ module Omnibus
include_examples 'a configurable', :project_root, Dir.pwd
include_examples 'a configurable', :local_software_dirs, []
include_examples 'a configurable', :software_gems, ['omnibus-software']
include_examples 'a configurable', :solaris_compiler, nil
include_examples 'a configurable', :solaris_linker_mapfile, 'files/mapfiles/solaris'
include_examples 'a configurable', :append_timestamp, true
include_examples 'a configurable', :build_retries, 0
include_examples 'a configurable', :use_git_caching, true
Expand Down
25 changes: 25 additions & 0 deletions spec/unit/software_spec.rb
Expand Up @@ -130,6 +130,31 @@ module Omnibus
'PKG_CONFIG_PATH' => '/opt/project/embedded/lib/pkgconfig'
)
end

context 'when loader mapping file is specified' do
before do
stub_ohai(platform: 'solaris2', version: '5.11') do |data|
# For some reason, this isn't set in Fauxhai
data['platform'] = 'solaris2'
end
Config.project_root('/root/project')
Config.solaris_linker_mapfile('files/mapfile/solaris')
allow(File).to receive(:exist?).and_return(true)
end

it 'sets LD_OPTIONS correctly' do
expect(subject.with_standard_compiler_flags).to eq(
'CC' => 'gcc -static-libgcc',
'LDFLAGS' => '-R/opt/project/embedded/lib -L/opt/project/embedded/lib -static-libgcc',
'CFLAGS' => '-I/opt/project/embedded/include',
"CXXFLAGS" => "-I/opt/project/embedded/include",
"CPPFLAGS" => "-I/opt/project/embedded/include",
'LD_RUN_PATH' => '/opt/project/embedded/lib',
'LD_OPTIONS' => '-R/opt/project/embedded/lib -M /root/project/files/mapfile/solaris',
'PKG_CONFIG_PATH' => '/opt/project/embedded/lib/pkgconfig'
)
end
end
end

context 'on mac_os_x' do
Expand Down

0 comments on commit 7be82bc

Please sign in to comment.