diff options
author | Andrey Parfenov <andrey.parfenov@intel.com> | 2023-06-18 23:07:08 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-18 14:07:08 -0700 |
commit | 7dc485d2887c70e3e1ebdc6f680cda926444da72 (patch) | |
tree | 192308fa3285ff4ce2aa5fcefbfe0fc8a3b191af /var | |
parent | 5c6c3b403bc4a8cd08b4e9303748933f3f79f5f7 (diff) | |
download | spack-7dc485d2887c70e3e1ebdc6f680cda926444da72.tar.gz spack-7dc485d2887c70e3e1ebdc6f680cda926444da72.tar.bz2 spack-7dc485d2887c70e3e1ebdc6f680cda926444da72.tar.xz spack-7dc485d2887c70e3e1ebdc6f680cda926444da72.zip |
cc: Ensure that user-specified flags take precedence over others (#37376)
Spack flags supplied by users should supersede flags from package build systems and
other places in Spack. However, Spack currently adds user-supplied flags to the
beginning of the compile line, which means that in some cases build system flags will
supersede user-supplied ones.
The right place to add a flag to ensure it has highest precedence for the compiler really
depends on the type of flag. For example, search paths like `-L` and `-I` are examined
in order, so adding them first is highest precedence. Compilers take the *last* occurrence
of optimization flags like `-O2`, so those should be placed *after* other such flags. Shim
libraries with `-l` should go *before* other libraries on the command line, so we want
user-supplied libs to go first, etc.
`lib/spack/env/cc` already knows how to split arguments into categories like `libs_list`,
`rpath_dirs_list`, etc., so we can leverage that functionality to merge user flags into
the arg list correctly.
The general rules for injected flags are:
1. All `-L`, `-I`, `-isystem`, `-l`, and `*-rpath` flags from `spack_flags_*` to appear
before their regular counterparts.
2. All other flags ordered with the ones from flags after their regular counterparts,
i.e. `other_flags` before `spack_flags_other_flags`
- [x] Generalize argument categorization into its own function in the `cc` shell script
- [x] Apply the same splitting logic to injected flags and flags from the original compile line.
- [x] Use the resulting flag lists to merge user- and build-system-supplied flags by category.
- [x] Add tests.
Signed-off-by: Andrey Parfenov <andrey.parfenov@intel.com>
Co-authored-by: iermolae <igor.ermolaev@intel.com>
Diffstat (limited to 'var')
0 files changed, 0 insertions, 0 deletions