[MacPorts] #57695: Set AR, NM and RANLIB env. variables

MacPorts noreply at macports.org
Wed Nov 28 10:05:27 UTC 2018


#57695: Set AR, NM and RANLIB env. variables
-------------------------+--------------------
 Reporter:  RJVB         |      Owner:  (none)
     Type:  enhancement  |     Status:  new
 Priority:  Normal       |  Milestone:
Component:  base         |    Version:
 Keywords:               |       Port:
-------------------------+--------------------
 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}]
         }
     }
 }}}

-- 
Ticket URL: <https://trac.macports.org/ticket/57695>
MacPorts <https://www.macports.org/>
Ports system for macOS


More information about the macports-tickets mailing list