summaryrefslogtreecommitdiff
path: root/lib/spack/spack/build_environment.py
diff options
context:
space:
mode:
authorGregory Becker <becker33@llnl.gov>2018-08-04 21:30:17 -0700
committerTodd Gamblin <tgamblin@llnl.gov>2018-08-08 01:51:51 -0700
commit683c7fbf3bff72535964afdd93a214748ff253a6 (patch)
tree104594753fa5d24d75423a4acbc33f1d88d25008 /lib/spack/spack/build_environment.py
parentf152063898051de6187a33af542a9f1492ae887a (diff)
downloadspack-683c7fbf3bff72535964afdd93a214748ff253a6.tar.gz
spack-683c7fbf3bff72535964afdd93a214748ff253a6.tar.bz2
spack-683c7fbf3bff72535964afdd93a214748ff253a6.tar.xz
spack-683c7fbf3bff72535964afdd93a214748ff253a6.zip
Restore cc: package search paths come before dependency paths (#4692)
Spack currently prepends include paths, library paths, and rpaths to the compile line. This causes problems when a header or library in the package has the same name as one exported by one of its dependencies. The *dependency's* header will be preferred over the package's, which is not what most builds expect. This also breaks some of our production codes. This restores the original cc behavior (from *very* early Spack) of parsing compiler arguments out by type (`-L`, `-I`, `-Wl,-rpath`) and reconstituting the full command at the end. `<includes> <other_args> <library dirs> <rpaths>` This differs from the original behavior in one significant way, though: it *appends* the library arguments so that dependency libraries do not shadow those in the build. This is safe because semantics aren't affected by *interleaving* `-I`, `-L`, and `-Wl,-rpath` arguments with others, only with each other (so the order of two `-L` args affects the search path, but we search for all libraries on the command line using the same search path). We preserve the following: 1. Any system directory in the paths will be listed last. 2. The root package's include/library/RPATH flags come before flags of the same type for any dependency. 3. Order will be preserved within flags passed by the build (except system paths, which are moved to be last) 4. Flags for dependencies will appear between the root flags and the system flags, and the flags for any dependency will come before those for *its* dependencies (this is for completeness -- we already guarantee this in `build_environment.py`)
Diffstat (limited to 'lib/spack/spack/build_environment.py')
-rw-r--r--lib/spack/spack/build_environment.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/spack/spack/build_environment.py b/lib/spack/spack/build_environment.py
index e48e570e76..ea18cc87d0 100644
--- a/lib/spack/spack/build_environment.py
+++ b/lib/spack/spack/build_environment.py
@@ -73,6 +73,7 @@ import spack.store
from spack.environment import EnvironmentModifications, validate
from spack.environment import preserve_environment
from spack.util.environment import env_flag, filter_system_paths, get_path
+from spack.util.environment import system_dirs
from spack.util.executable import Executable
from spack.util.module_cmd import load_module, get_path_from_module
from spack.util.log_parse import parse_log_events, make_log_context
@@ -99,6 +100,7 @@ SPACK_SHORT_SPEC = 'SPACK_SHORT_SPEC'
SPACK_DEBUG_LOG_ID = 'SPACK_DEBUG_LOG_ID'
SPACK_DEBUG_LOG_DIR = 'SPACK_DEBUG_LOG_DIR'
SPACK_CCACHE_BINARY = 'SPACK_CCACHE_BINARY'
+SPACK_SYSTEM_DIRS = 'SPACK_SYSTEM_DIRS'
# Platform-specific library suffix.
@@ -202,6 +204,8 @@ def set_compiler_environment_variables(pkg, env):
env.set('SPACK_COMPILER_SPEC', str(pkg.spec.compiler))
+ env.set('SPACK_SYSTEM_DIRS', ' '.join(system_dirs))
+
compiler.setup_custom_environment(pkg, env)
return env