Repository: spack/spack

Issue:
cmake build using clang fails with post 7/10/2018 branch
On MacOSX-10.13.4 and clang-9.1.0-apple compiler, an older version of spack (downloaded 7/10/2018) builds cmake-3.11.0 fine.

Using the same system with a later spack version (downloaded 8/3/2018) fails on cmake-3.11.0 build in bootstrap phase with error:

`The C++ compiler does not support C++11 (std::unique_ptr).`

The exact same package.py was used for both build processes (attached). 

[package.py.txt](https://github.com/spack/spack/files/2258686/package.py.txt)



Discussion:
Please use ‘git bisect’ to track the first commit that broke it
$ git bisect bad
cd9691de5314fcfaf17d47a63264acef5716c0b6 is the first bad commit
commit cd9691de5314fcfaf17d47a63264acef5716c0b6
Author: becker33 <becker33@llnl.gov>
Date:   Wed Aug 1 15:48:00 2018 -0700

    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 fo 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`)

:040000 040000 5276ebe4fd2507993cd14a2413b3bf28a17214b2 73def5031cfee2fdfa2f3b1bf8d3043e06a7bc0c M    lib
@becker33 another issue related to https://github.com/spack/spack/pull/4692

Resolving patch:
diff --git a/lib/spack/spack/build_environment.py b/lib/spack/spack/build_environment.py
--- a/lib/spack/spack/build_environment.py
+++ b/lib/spack/spack/build_environment.py
@@ -73,7 +73,6 @@
 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
@@ -100,7 +99,6 @@
 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.
@@ -204,8 +202,6 @@ 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


Test patch:
diff --git a/lib/spack/spack/test/build_environment.py b/lib/spack/spack/test/build_environment.py
--- a/lib/spack/spack/test/build_environment.py
+++ b/lib/spack/spack/test/build_environment.py
@@ -58,8 +58,6 @@ def build_environment():
     os.environ['SPACK_F77_RPATH_ARG'] = "-Wl,-rpath,"
     os.environ['SPACK_FC_RPATH_ARG']  = "-Wl,-rpath,"
 
-    os.environ['SPACK_SYSTEM_DIRS'] = '/usr/include /usr/lib'
-
     if 'SPACK_DEPENDENCIES' in os.environ:
         del os.environ['SPACK_DEPENDENCIES']
 
@@ -69,8 +67,7 @@ def build_environment():
                  'SPACK_ENV_PATH', 'SPACK_DEBUG_LOG_DIR',
                  'SPACK_COMPILER_SPEC', 'SPACK_SHORT_SPEC',
                  'SPACK_CC_RPATH_ARG', 'SPACK_CXX_RPATH_ARG',
-                 'SPACK_F77_RPATH_ARG', 'SPACK_FC_RPATH_ARG',
-                 'SPACK_SYSTEM_DIRS'):
+                 'SPACK_F77_RPATH_ARG', 'SPACK_FC_RPATH_ARG'):
         del os.environ[name]
 
 
@@ -99,8 +96,8 @@ def test_static_to_shared_library(build_environment):
                 shared_lib = '{0}.{1}'.format(
                     os.path.splitext(static_lib)[0], dso_suffix)
 
-            assert set(output.split()) == set(expected[arch].format(
-                static_lib, shared_lib, os.path.basename(shared_lib)).split())
+            assert output == expected[arch].format(
+                static_lib, shared_lib, os.path.basename(shared_lib))
 
 
 @pytest.mark.regression('8345')
diff --git a/lib/spack/spack/test/cc.py b/lib/spack/spack/test/cc.py
--- a/lib/spack/spack/test/cc.py
+++ b/lib/spack/spack/test/cc.py
@@ -166,71 +166,50 @@ def test_flags(self):
 
         # Test ldflags added properly in ld mode
         self.check_ld('dump-args', test_command,
-                      'ld -L foo ' +
-                      '-I/test/include -I/other/include arg1 ' +
-                      '-Wl,--start-group arg2 arg3 -llib1 -llib2 arg4 ' +
-                      '-Wl,--end-group ' +
-                      '-llib3 -llib4 arg5 arg6 ' +
-                      '-L/test/lib -L/other/lib ' +
-                      '-lfoo ' +
-                      '-rpath /first/rpath -rpath /second/rpath ' +
-                      '-rpath /third/rpath -rpath /fourth/rpath ' +
-                      '-rpath /spack-test-prefix/lib ' +
-                      '-rpath /spack-test-prefix/lib64')
+                      "ld " +
+                      '-rpath ' + self.prefix + '/lib ' +
+                      '-rpath ' + self.prefix + '/lib64 ' +
+                      '-L foo ' +
+                      ' '.join(test_command) + ' ' +
+                      '-lfoo')
 
         # Test cppflags added properly in cpp mode
         self.check_cpp('dump-args', test_command,
                        "cpp " +
                        '-g -O1 ' +
-                       '-I/test/include -I/other/include arg1 ' +
-                       '-Wl,--start-group arg2 arg3 -llib1 -llib2 arg4 ' +
-                       '-Wl,--end-group ' +
-                       '-llib3 -llib4 arg5 arg6 ' +
-                       '-L/test/lib -L/other/lib')
+                       ' '.join(test_command))
 
         # Test ldflags, cppflags, and language specific flags are added in
         # proper order
         self.check_cc('dump-args', test_command,
                       self.realcc + ' ' +
-                      '-g -O1 -Wall -L foo ' +
-                      '-I/test/include -I/other/include arg1 ' +
-                      '-Wl,--start-group arg2 arg3 -llib1 -llib2 arg4 ' +
-                      '-Wl,--end-group ' +
-                      '-llib3 -llib4 arg5 arg6 ' +
-                      '-L/test/lib -L/other/lib ' +
-                      '-lfoo ' +
-                      '-Wl,-rpath,/first/rpath -Wl,-rpath,/second/rpath ' +
-                      '-Wl,-rpath,/third/rpath -Wl,-rpath,/fourth/rpath ' +
-                      '-Wl,-rpath,/spack-test-prefix/lib ' +
-                      '-Wl,-rpath,/spack-test-prefix/lib64')
+                      '-Wl,-rpath,' + self.prefix + '/lib ' +
+                      '-Wl,-rpath,' + self.prefix + '/lib64 ' +
+                      '-g -O1 ' +
+                      '-Wall ' +
+                      '-L foo ' +
+                      ' '.join(test_command) + ' ' +
+                      '-lfoo')
 
         self.check_cxx('dump-args', test_command,
                        self.realcc + ' ' +
-                       '-g -O1 -Werror -L foo ' +
-                       '-I/test/include -I/other/include arg1 ' +
-                       '-Wl,--start-group arg2 arg3 -llib1 -llib2 arg4 ' +
-                       '-Wl,--end-group ' +
-                       '-llib3 -llib4 arg5 arg6 ' +
-                       '-L/test/lib -L/other/lib ' +
-                       '-lfoo ' +
-                       '-Wl,-rpath,/first/rpath -Wl,-rpath,/second/rpath ' +
-                       '-Wl,-rpath,/third/rpath -Wl,-rpath,/fourth/rpath ' +
-                       '-Wl,-rpath,/spack-test-prefix/lib ' +
-                       '-Wl,-rpath,/spack-test-prefix/lib64')
+                       '-Wl,-rpath,' + self.prefix + '/lib ' +
+                       '-Wl,-rpath,' + self.prefix + '/lib64 ' +
+                       '-g -O1 ' +
+                       '-Werror ' +
+                       '-L foo ' +
+                       ' '.join(test_command) + ' ' +
+                       '-lfoo')
 
         self.check_fc('dump-args', test_command,
                       self.realcc + ' ' +
-                      '-w -g -O1 -L foo ' +
-                      '-I/test/include -I/other/include arg1 ' +
-                      '-Wl,--start-group arg2 arg3 -llib1 -llib2 arg4 ' +
-                      '-Wl,--end-group ' +
-                      '-llib3 -llib4 arg5 arg6 ' +
-                      '-L/test/lib -L/other/lib ' +
-                      '-lfoo ' +
-                      '-Wl,-rpath,/first/rpath -Wl,-rpath,/second/rpath ' +
-                      '-Wl,-rpath,/third/rpath -Wl,-rpath,/fourth/rpath ' +
-                      '-Wl,-rpath,/spack-test-prefix/lib ' +
-                      '-Wl,-rpath,/spack-test-prefix/lib64')
+                      '-Wl,-rpath,' + self.prefix + '/lib ' +
+                      '-Wl,-rpath,' + self.prefix + '/lib64 ' +
+                      '-w ' +
+                      '-g -O1 ' +
+                      '-L foo ' +
+                      ' '.join(test_command) + ' ' +
+                      '-lfoo')
 
         del os.environ['SPACK_CFLAGS']
         del os.environ['SPACK_CXXFLAGS']
@@ -243,15 +222,9 @@ def test_dep_rpath(self):
         """Ensure RPATHs for root package are added."""
         self.check_cc('dump-args', test_command,
                       self.realcc + ' ' +
-                      '-I/test/include -I/other/include arg1 ' +
-                      '-Wl,--start-group arg2 arg3 -llib1 -llib2 arg4 ' +
-                      '-Wl,--end-group ' +
-                      '-llib3 -llib4 arg5 arg6 ' +
-                      '-L/test/lib -L/other/lib ' +
-                      '-Wl,-rpath,/first/rpath -Wl,-rpath,/second/rpath ' +
-                      '-Wl,-rpath,/third/rpath -Wl,-rpath,/fourth/rpath ' +
-                      '-Wl,-rpath,/spack-test-prefix/lib ' +
-                      '-Wl,-rpath,/spack-test-prefix/lib64')
+                      '-Wl,-rpath,' + self.prefix + '/lib ' +
+                      '-Wl,-rpath,' + self.prefix + '/lib64 ' +
+                      ' '.join(test_command))
 
     def test_dep_include(self):
         """Ensure a single dependency include directory is added."""
@@ -260,16 +233,10 @@ def test_dep_include(self):
         os.environ['SPACK_LINK_DEPS'] = os.environ['SPACK_DEPENDENCIES']
         self.check_cc('dump-args', test_command,
                       self.realcc + ' ' +
-                      '-I/test/include -I/other/include ' +
-                      '-I' + self.dep4 + '/include arg1 ' +
-                      '-Wl,--start-group arg2 arg3 -llib1 -llib2 arg4 ' +
-                      '-Wl,--end-group ' +
-                      '-llib3 -llib4 arg5 arg6 ' +
-                      '-L/test/lib -L/other/lib ' +
-                      '-Wl,-rpath,/first/rpath -Wl,-rpath,/second/rpath ' +
-                      '-Wl,-rpath,/third/rpath -Wl,-rpath,/fourth/rpath ' +
-                      '-Wl,-rpath,/spack-test-prefix/lib ' +
-                      '-Wl,-rpath,/spack-test-prefix/lib64')
+                      '-Wl,-rpath,' + self.prefix + '/lib ' +
+                      '-Wl,-rpath,' + self.prefix + '/lib64 ' +
+                      '-I' + self.dep4 + '/include ' +
+                      ' '.join(test_command))
 
     def test_dep_lib(self):
         """Ensure a single dependency RPATH is added."""
@@ -278,17 +245,11 @@ def test_dep_lib(self):
         os.environ['SPACK_LINK_DEPS'] = os.environ['SPACK_DEPENDENCIES']
         self.check_cc('dump-args', test_command,
                       self.realcc + ' ' +
-                      '-I/test/include -I/other/include arg1 ' +
-                      '-Wl,--start-group arg2 arg3 -llib1 -llib2 arg4 ' +
-                      '-Wl,--end-group ' +
-                      '-llib3 -llib4 arg5 arg6 ' +
-                      '-L/test/lib -L/other/lib ' +
+                      '-Wl,-rpath,' + self.prefix + '/lib ' +
+                      '-Wl,-rpath,' + self.prefix + '/lib64 ' +
                       '-L' + self.dep2 + '/lib64 ' +
-                      '-Wl,-rpath,/first/rpath -Wl,-rpath,/second/rpath ' +
-                      '-Wl,-rpath,/third/rpath -Wl,-rpath,/fourth/rpath ' +
-                      '-Wl,-rpath,/spack-test-prefix/lib ' +
-                      '-Wl,-rpath,/spack-test-prefix/lib64 ' +
-                      '-Wl,-rpath,' + self.dep2 + '/lib64')
+                      '-Wl,-rpath,' + self.dep2 + '/lib64 ' +
+                      ' '.join(test_command))
 
     def test_dep_lib_no_rpath(self):
         """Ensure a single dependency link flag is added with no dep RPATH."""
@@ -296,16 +257,10 @@ def test_dep_lib_no_rpath(self):
         os.environ['SPACK_LINK_DEPS'] = os.environ['SPACK_DEPENDENCIES']
         self.check_cc('dump-args', test_command,
                       self.realcc + ' ' +
-                      '-I/test/include -I/other/include arg1 ' +
-                      '-Wl,--start-group arg2 arg3 -llib1 -llib2 arg4 ' +
-                      '-Wl,--end-group ' +
-                      '-llib3 -llib4 arg5 arg6 ' +
-                      '-L/test/lib -L/other/lib ' +
+                      '-Wl,-rpath,' + self.prefix + '/lib ' +
+                      '-Wl,-rpath,' + self.prefix + '/lib64 ' +
                       '-L' + self.dep2 + '/lib64 ' +
-                      '-Wl,-rpath,/first/rpath -Wl,-rpath,/second/rpath ' +
-                      '-Wl,-rpath,/third/rpath -Wl,-rpath,/fourth/rpath ' +
-                      '-Wl,-rpath,/spack-test-prefix/lib ' +
-                      '-Wl,-rpath,/spack-test-prefix/lib64')
+                      ' '.join(test_command))
 
     def test_dep_lib_no_lib(self):
         """Ensure a single dependency RPATH is added with no -L."""
@@ -313,16 +268,10 @@ def test_dep_lib_no_lib(self):
         os.environ['SPACK_RPATH_DEPS'] = os.environ['SPACK_DEPENDENCIES']
         self.check_cc('dump-args', test_command,
                       self.realcc + ' ' +
-                      '-I/test/include -I/other/include arg1 ' +
-                      '-Wl,--start-group arg2 arg3 -llib1 -llib2 arg4 ' +
-                      '-Wl,--end-group ' +
-                      '-llib3 -llib4 arg5 arg6 ' +
-                      '-L/test/lib -L/other/lib ' +
-                      '-Wl,-rpath,/first/rpath -Wl,-rpath,/second/rpath ' +
-                      '-Wl,-rpath,/third/rpath -Wl,-rpath,/fourth/rpath ' +
-                      '-Wl,-rpath,/spack-test-prefix/lib ' +
-                      '-Wl,-rpath,/spack-test-prefix/lib64 ' +
-                      '-Wl,-rpath,' + self.dep2 + '/lib64')
+                      '-Wl,-rpath,' + self.prefix + '/lib ' +
+                      '-Wl,-rpath,' + self.prefix + '/lib64 ' +
+                      '-Wl,-rpath,' + self.dep2 + '/lib64 ' +
+                      ' '.join(test_command))
 
     def test_all_deps(self):
         """Ensure includes and RPATHs for all deps are added. """
@@ -336,25 +285,23 @@ def test_all_deps(self):
         # to.  We could loosen that if it becomes necessary
         self.check_cc('dump-args', test_command,
                       self.realcc + ' ' +
-                      '-I/test/include -I/other/include ' +
-                      '-I' + self.dep1 + '/include ' +
-                      '-I' + self.dep3 + '/include ' +
+                      '-Wl,-rpath,' + self.prefix + '/lib ' +
+                      '-Wl,-rpath,' + self.prefix + '/lib64 ' +
+
                       '-I' + self.dep4 + '/include ' +
-                      'arg1 ' +
-                      '-Wl,--start-group arg2 arg3 -llib1 -llib2 arg4 ' +
-                      '-Wl,--end-group ' +
-                      '-llib3 -llib4 arg5 arg6 ' +
-                      '-L/test/lib -L/other/lib ' +
-                      '-L' + self.dep1 + '/lib ' +
-                      '-L' + self.dep2 + '/lib64 ' +
+
                       '-L' + self.dep3 + '/lib64 ' +
-                      '-Wl,-rpath,/first/rpath -Wl,-rpath,/second/rpath ' +
-                      '-Wl,-rpath,/third/rpath -Wl,-rpath,/fourth/rpath ' +
-                      '-Wl,-rpath,/spack-test-prefix/lib ' +
-                      '-Wl,-rpath,/spack-test-prefix/lib64 ' +
-                      '-Wl,-rpath,' + self.dep1 + '/lib ' +
+                      '-Wl,-rpath,' + self.dep3 + '/lib64 ' +
+                      '-I' + self.dep3 + '/include ' +
+
+                      '-L' + self.dep2 + '/lib64 ' +
                       '-Wl,-rpath,' + self.dep2 + '/lib64 ' +
-                      '-Wl,-rpath,' + self.dep3 + '/lib64')
+
+                      '-L' + self.dep1 + '/lib ' +
+                      '-Wl,-rpath,' + self.dep1 + '/lib ' +
+                      '-I' + self.dep1 + '/include ' +
+
+                      ' '.join(test_command))
 
     def test_ld_deps(self):
         """Ensure no (extra) -I args or -Wl, are passed in ld mode."""
@@ -365,22 +312,19 @@ def test_ld_deps(self):
 
         self.check_ld('dump-args', test_command,
                       'ld ' +
-                      '-I/test/include -I/other/include ' +
-                      'arg1 ' +
-                      '-Wl,--start-group arg2 arg3 -llib1 -llib2 arg4 ' +
-                      '-Wl,--end-group ' +
-                      '-llib3 -llib4 arg5 arg6 ' +
-                      '-L/test/lib -L/other/lib ' +
-                      '-L' + self.dep1 + '/lib ' +
-                      '-L' + self.dep2 + '/lib64 ' +
+                      '-rpath ' + self.prefix + '/lib ' +
+                      '-rpath ' + self.prefix + '/lib64 ' +
+
                       '-L' + self.dep3 + '/lib64 ' +
-                      '-rpath /first/rpath -rpath /second/rpath ' +
-                      '-rpath /third/rpath -rpath /fourth/rpath ' +
-                      '-rpath /spack-test-prefix/lib ' +
-                      '-rpath /spack-test-prefix/lib64 ' +
-                      '-rpath ' + self.dep1 + '/lib ' +
+                      '-rpath ' + self.dep3 + '/lib64 ' +
+
+                      '-L' + self.dep2 + '/lib64 ' +
                       '-rpath ' + self.dep2 + '/lib64 ' +
-                      '-rpath ' + self.dep3 + '/lib64')
+
+                      '-L' + self.dep1 + '/lib ' +
+                      '-rpath ' + self.dep1 + '/lib ' +
+
+                      ' '.join(test_command))
 
     def test_ld_deps_no_rpath(self):
         """Ensure SPACK_RPATH_DEPS controls RPATHs for ld."""
@@ -390,19 +334,14 @@ def test_ld_deps_no_rpath(self):
 
         self.check_ld('dump-args', test_command,
                       'ld ' +
-                      '-I/test/include -I/other/include ' +
-                      'arg1 ' +
-                      '-Wl,--start-group arg2 arg3 -llib1 -llib2 arg4 ' +
-                      '-Wl,--end-group ' +
-                      '-llib3 -llib4 arg5 arg6 ' +
-                      '-L/test/lib -L/other/lib ' +
-                      '-L' + self.dep1 + '/lib ' +
-                      '-L' + self.dep2 + '/lib64 ' +
+                      '-rpath ' + self.prefix + '/lib ' +
+                      '-rpath ' + self.prefix + '/lib64 ' +
+
                       '-L' + self.dep3 + '/lib64 ' +
-                      '-rpath /first/rpath -rpath /second/rpath ' +
-                      '-rpath /third/rpath -rpath /fourth/rpath ' +
-                      '-rpath /spack-test-prefix/lib ' +
-                      '-rpath /spack-test-prefix/lib64')
+                      '-L' + self.dep2 + '/lib64 ' +
+                      '-L' + self.dep1 + '/lib ' +
+
+                      ' '.join(test_command))
 
     def test_ld_deps_no_link(self):
         """Ensure SPACK_LINK_DEPS controls -L for ld."""
@@ -412,19 +351,14 @@ def test_ld_deps_no_link(self):
 
         self.check_ld('dump-args', test_command,
                       'ld ' +
-                      '-I/test/include -I/other/include ' +
-                      'arg1 ' +
-                      '-Wl,--start-group arg2 arg3 -llib1 -llib2 arg4 ' +
-                      '-Wl,--end-group ' +
-                      '-llib3 -llib4 arg5 arg6 ' +
-                      '-L/test/lib -L/other/lib ' +
-                      '-rpath /first/rpath -rpath /second/rpath ' +
-                      '-rpath /third/rpath -rpath /fourth/rpath ' +
-                      '-rpath /spack-test-prefix/lib ' +
-                      '-rpath /spack-test-prefix/lib64 ' +
-                      '-rpath ' + self.dep1 + '/lib ' +
+                      '-rpath ' + self.prefix + '/lib ' +
+                      '-rpath ' + self.prefix + '/lib64 ' +
+
+                      '-rpath ' + self.dep3 + '/lib64 ' +
                       '-rpath ' + self.dep2 + '/lib64 ' +
-                      '-rpath ' + self.dep3 + '/lib64')
+                      '-rpath ' + self.dep1 + '/lib ' +
+
+                      ' '.join(test_command))
 
     def test_ld_deps_reentrant(self):
         """Make sure ld -r is handled correctly on OS's where it doesn't
@@ -437,30 +371,18 @@ def test_ld_deps_reentrant(self):
         reentrant_test_command = ['-r'] + test_command
         self.check_ld('dump-args', reentrant_test_command,
                       'ld ' +
-                      '-I/test/include -I/other/include ' +
-                      '-r arg1 ' +
-                      '-Wl,--start-group arg2 arg3 -llib1 -llib2 arg4 ' +
-                      '-Wl,--end-group ' +
-                      '-llib3 -llib4 arg5 arg6 ' +
-                      '-L/test/lib -L/other/lib ' +
+                      '-rpath ' + self.prefix + '/lib ' +
+                      '-rpath ' + self.prefix + '/lib64 ' +
+
                       '-L' + self.dep1 + '/lib ' +
-                      '-rpath /first/rpath -rpath /second/rpath ' +
-                      '-rpath /third/rpath -rpath /fourth/rpath ' +
-                      '-rpath /spack-test-prefix/lib ' +
-                      '-rpath /spack-test-prefix/lib64 ' +
-                      '-rpath ' + self.dep1 + '/lib')
-
-        # rpaths from the underlying command will still appear
-        # Spack will not add its own rpaths.
+                      '-rpath ' + self.dep1 + '/lib ' +
+
+                      '-r ' +
+                      ' '.join(test_command))
+
         os.environ['SPACK_SHORT_SPEC'] = "foo@1.2=darwin-x86_64"
         self.check_ld('dump-args', reentrant_test_command,
                       'ld ' +
-                      '-I/test/include -I/other/include ' +
-                      '-r arg1 ' +
-                      '-Wl,--start-group arg2 arg3 -llib1 -llib2 arg4 ' +
-                      '-Wl,--end-group ' +
-                      '-llib3 -llib4 arg5 arg6 ' +
-                      '-L/test/lib -L/other/lib ' +
                       '-L' + self.dep1 + '/lib ' +
-                      '-rpath /first/rpath -rpath /second/rpath ' +
-                      '-rpath /third/rpath -rpath /fourth/rpath')
+                      '-r ' +
+                      ' '.join(test_command))