Skip to content
This repository has been archived by the owner on Mar 20, 2023. It is now read-only.

Respect CMAKE_EXE_LINKER_FLAGS/CMAKE_SHARED_LINKER_FLAGS flags set via CLI #830

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

pramodk
Copy link
Collaborator

@pramodk pramodk commented Jun 22, 2022

Description

In the case of Clang, we were always overriding the above-mentioned flags
and hence cmake args were ignored (resulting in link errors)

How to test this?

On BB5 with Clang compiler

module load unstable gcc llvm hpe-mpi cmake python-dev flex bison
cmake .. -DCMAKE_INSTALL_PREFIX=`pwd`/install -DCORENRN_ENABLE_GPU=OFF -DCORENRN_ENABLE_NMODL=OFF -DCORENRN_ENABLE_MPI=ON  -DNRN_ENABLE_CORENEURON=ON -DNRN_ENABLE_INTERVIEWS=OFF -DNRN_ENABLE_TESTS=OFF '-DCMAKE_EXE_LINKER_FLAGS=-L/gpfs/bbp.cscs.ch/home/kumbhar/spack_install/software/install_gcc-11.2.0-skylake/intel-oneapi-mkl-2021.4.0-gbepe3/compiler/2021.4.0/linux/compiler/lib/intel64_lin -lsvml -lintlc -Wl,-rpath,/gpfs/bbp.cscs.ch/home/kumbhar/spack_install/software/install_gcc-11.2.0-skylake/intel-oneapi-mkl-2021.4.0-gbepe3/compiler/2021.4.0/linux/compiler/lib/intel64_lin' '-DCMAKE_CXX_FLAGS=-Rpass=loop-vectorize -Rpass-missed=loop-vectorize -Rpass-analysis=loop-vectorize -fsave-optimization-record -O3 -march=skylake-avx512 -mtune=skylake -ffast-math -fopenmp-simd -fveclib=SVML'
make -j8

Test System

BB5

…a CLI

In case of Clang, we were always overriding the above mentioned flags
and hence cmake args were ignored (resuliting in link errors)
@pramodk pramodk requested review from alkino and olupton June 22, 2022 08:01
@pramodk pramodk force-pushed the pramodk/omp-simd branch from 010d8c6 to 6f9c31e Compare June 22, 2022 08:27
@@ -113,8 +113,8 @@ foreach(COMPILER_LANGUAGE ${SUPPORTED_COMPILER_LANGUAGE_LIST})
# Force same ld behavior as when called from gcc --as-needed forces the linker to check whether
# a dynamic library mentioned in the command line is actually needed by the objects being
# linked. Symbols needed in shared objects are already linked when building that library.
set(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--as-needed")
set(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed ${CMAKE_EXE_LINKER_FLAGS}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use https://cmake.org/cmake/help/latest/command/string.html#append to avoid repeating the variable name, I think, but no big deal.

-I$(CORENRN_INC_DIR) $(INCFLAGS) \
-L$(OUTPUT_DIR) -l$(COREMECH_LIB_NAME) $(CORENRNLIB_FLAGS) $(LDFLAGS) \
-L$(OUTPUT_DIR) -l$(COREMECH_LIB_NAME) $(CORENRNLIB_FLAGS) $(LDFLAGS) $(CXX_LINK_EXE_FLAGS) \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I can see the changes to this file just re-order some flags. Is that important?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I now see the commit message about it needing to be later. Can you add a comment/documentation about that issue/detail?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, I should have put this PR in draft - haven't thoroughly checked how/why -Wl,--as-needed causes this but I remember this flag was needed in case wheel building. I will check this bit later and get back here.

@pramodk pramodk marked this pull request as draft September 19, 2022 19:42
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants