Opened 6 years ago
Last modified 6 years ago
#57695 new enhancement
Set AR, NM and RANLIB env. variables — at Initial Version
Reported by: | RJVB (René Bertin) | Owned by: | |
---|---|---|---|
Priority: | Normal | Milestone: | |
Component: | base | Version: | |
Keywords: | Cc: | ||
Port: |
Description
I like to use link time optimisation where feasible and have learned through experience that this can cause link failures in projects that use static libraries (intermediate/private and/or public). This can be avoided by using a more homogeneous toolchain, i.e.
if {[string match *clang++-mp* ${configure.cxx}]} { configure.env-append \ AR="[string map {"clang++" "llvm-ar"} ${configure.cxx}]" \ NM="[string map {"clang++" "llvm-nm"} ${configure.cxx}]" \ RANLIB="[string map {"clang++" "llvm-ranlib"} ${configure.cxx}]" } elseif {[string match *clang-mp* ${configure.cc}]} { configure.env-append \ AR="[string map {"clang" "llvm-ar"} ${configure.cc}]" \ NM="[string map {"clang" "llvm-nm"} ${configure.cc}]" \ RANLIB="[string map {"clang" "llvm-ranlib"} ${configure.cc}]" }
The mentioned experience comes from Linux but I don't see why similar issues couldn't arise on Mac, for similar reasons (the default ar and/or ranlib not being able to create a usable static library from llvm objects). I think it shouldn't hurt to set the AR, NM and RANLIB env. variables as shown above from "base", along with CC, CXX etc.
Equivalent for in the cmake PortGroup (pre-configure block):
if {[string match *clang++-mp* ${configure.cxx}]} { if {[string first "DCMAKE_AR=" ${configure.args}] eq -1} { configure.args-append \ -DCMAKE_AR=[string map {"clang++" "llvm-ar"} ${configure.cxx}] } if {[string first "DCMAKE_NM=" ${configure.args}] eq -1} { configure.args-append \ -DCMAKE_NM=[string map {"clang++" "llvm-nm"} ${configure.cxx}] } if {[string first "DCMAKE_RANLIB=" ${configure.args}] eq -1} { configure.args-append \ -DCMAKE_RANLIB=[string map {"clang++" "llvm-ranlib"} ${configure.cxx}] } } elseif {[string match *clang-mp* ${configure.cc}]} { if {[string first "DCMAKE_AR=" ${configure.args}] eq -1} { configure.args-append \ -DCMAKE_AR=[string map {"clang" "llvm-ar"} ${configure.cc}] } if {[string first "DCMAKE_NM=" ${configure.args}] eq -1} { configure.args-append \ -DCMAKE_NM=[string map {"clang" "llvm-nm"} ${configure.cc}] } if {[string first "DCMAKE_RANLIB=" ${configure.args}] eq -1} { configure.args-append \ -DCMAKE_RANLIB=[string map {"clang" "llvm-ranlib"} ${configure.cc}] } }
Note: See
TracTickets for help on using
tickets.