[MacPorts] #67725: makefile portgroup and muniversal portgroups do not work together

MacPorts noreply at macports.org
Fri Jul 7 07:19:02 UTC 2023


#67725: makefile portgroup and muniversal portgroups do not work together
------------------------+----------------------
 Reporter:  ryandesign  |      Owner:  (none)
     Type:  defect      |     Status:  new
 Priority:  Normal      |  Milestone:
Component:  ports       |    Version:
 Keywords:              |       Port:  makefile
------------------------+----------------------
 There is code in the makefile portgroup presumably intended to make it
 work with the munivesal portgroups but it doesn't work for me.

 I am trying to add the muniversal portgroup (either 1.0 or 1.1) to the
 zpaq port (which already uses the makefile 1.0 portgroup) to fix #67552. I
 need to add a flag to CPPFLAGS for non-Intel architectures. In addition,
 of course, I need correct `-arch` flags on all compiles and links.

 Without the muniversal portgroup, correct `-arch` flags are used on all
 compiles and links.

 When I add the muniversal 1.1 portgroup, then `-arch` flags are used on
 compiles but not on links. And the CPPFLAGS I've specified are not added.

 Using this change to the zpaq Portfile:

 {{{#!diff
 diff --git a/archivers/zpaq/Portfile b/archivers/zpaq/Portfile
 index 543fa48b132..c5c32fae231 100644
 --- a/archivers/zpaq/Portfile
 +++ b/archivers/zpaq/Portfile
 @@ -3,9 +3,10 @@
  PortSystem          1.0
  PortGroup           github 1.0
  PortGroup           makefile 1.0
 +PortGroup           muniversal 1.1

  github.setup        zpaq zpaq 7.15
 -revision            0
 +revision            1
  checksums           rmd160  a8686308a5ffb9f4168f8afa6562b4c7b703b2c9 \
                      sha256
 64280d86cd38ad5ebc1c6415b17eb09ee292078d772176b90e16287687191efe \
                      size    140057
 @@ -41,6 +42,11 @@ if {[string match *clang* ${configure.cxx}] &&
 ${configure.cxx_stdlib} ne ""} {
      configure.ldflags-append -stdlib=${configure.cxx_stdlib}
  }

 +configure.cppflags.arm64    -DNOJIT
 +configure.cppflags.ppc      -DNOJIT
 +configure.cppflags.ppc64    -DNOJIT
 +configure.cppflags.x86_64   -DJUST_TESTING
 +
  test.run            yes
  test.target         check

 }}}

 I'm on an x86_64 Mac and building non-universal I get:

 {{{
 --->  Building zpaq
 DEBUG: Executing proc-pre-org.macports.build-build-0
 DEBUG: Executing org.macports.build (zpaq)
 DEBUG: Environment:
 ARCHPREFERENCE='x86_64'
 CC='/opt/local/var/macports/build/_Volumes_Shared_macports-
 ports_archivers_zpaq/zpaq/work/compwrap/cc/usr/bin/clang'
 CC_PRINT_OPTIONS='YES'
 CC_PRINT_OPTIONS_FILE='/opt/local/var/macports/build
 /_Volumes_Shared_macports-
 ports_archivers_zpaq/zpaq/work/.CC_PRINT_OPTIONS'
 CFLAGS='-Os
 -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk'
 CPATH='/opt/local/include'
 CPPFLAGS='-I/opt/local/include
 -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk'
 CXX='/opt/local/var/macports/build/_Volumes_Shared_macports-
 ports_archivers_zpaq/zpaq/work/compwrap/cxx/usr/bin/clang++'
 CXXFLAGS='-Os
 -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk
 -stdlib=libc++'
 DEVELOPER_DIR='/Library/Developer/CommandLineTools'
 F90FLAGS='-Os'
 FCFLAGS='-Os'
 FFLAGS='-Os'
 INSTALL='/usr/bin/install -c'
 LDFLAGS='-L/opt/local/lib -Wl,-headerpad_max_install_names -stdlib=libc++
 -Wl,-syslibroot,/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk'
 LIBRARY_PATH='/opt/local/lib'
 MACOSX_DEPLOYMENT_TARGET='12.0'
 OBJC='/opt/local/var/macports/build/_Volumes_Shared_macports-
 ports_archivers_zpaq/zpaq/work/compwrap/objc/usr/bin/clang'
 OBJCFLAGS='-Os
 -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk'
 OBJCXX='/opt/local/var/macports/build/_Volumes_Shared_macports-
 ports_archivers_zpaq/zpaq/work/compwrap/objcxx/usr/bin/clang++'
 OBJCXXFLAGS='-Os
 -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk
 -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk
 -stdlib=libc++'
 PREFIX='/opt/local'
 SDKROOT='/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk'
 }}}

 Why are the `-arch` flags and my `-DJUST_TESTING` addition to CPPFLAGS not
 appearing here in the environment variables? This is where I expect to see
 them.

 {{{
 Executing:  cd "/opt/local/var/macports/build/_Volumes_Shared_macports-
 ports_archivers_zpaq/zpaq/work/zpaq-7.15" && /usr/bin/make -j1 -w all
 PREFIX=/opt/local CC="/opt/local/var/macports/build
 /_Volumes_Shared_macports-
 ports_archivers_zpaq/zpaq/work/compwrap/cc/usr/bin/clang"
 CXX="/opt/local/var/macports/build/_Volumes_Shared_macports-
 ports_archivers_zpaq/zpaq/work/compwrap/cxx/usr/bin/clang++"
 OBJC="/opt/local/var/macports/build/_Volumes_Shared_macports-
 ports_archivers_zpaq/zpaq/work/compwrap/objc/usr/bin/clang"
 OBJCXX="/opt/local/var/macports/build/_Volumes_Shared_macports-
 ports_archivers_zpaq/zpaq/work/compwrap/objcxx/usr/bin/clang++"
 CXXFLAGS="-Os
 -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk
 -stdlib=libc++" INSTALL="/usr/bin/install -c" CC+="-arch x86_64"
 CXXFLAGS+="-arch x86_64" OBJC+="-arch x86_64" OBJCXX+="-arch x86_64"
 LD+="-arch x86_64" F77+="-m64" F90+="-m64" FC+="-m64"
 CPP+="-DJUST_TESTING"
 DEBUG: system:  cd "/opt/local/var/macports/build
 /_Volumes_Shared_macports-ports_archivers_zpaq/zpaq/work/zpaq-7.15" &&
 /usr/bin/make -j1 -w all PREFIX=/opt/local
 CC="/opt/local/var/macports/build/_Volumes_Shared_macports-
 ports_archivers_zpaq/zpaq/work/compwrap/cc/usr/bin/clang"
 CXX="/opt/local/var/macports/build/_Volumes_Shared_macports-
 ports_archivers_zpaq/zpaq/work/compwrap/cxx/usr/bin/clang++"
 OBJC="/opt/local/var/macports/build/_Volumes_Shared_macports-
 ports_archivers_zpaq/zpaq/work/compwrap/objc/usr/bin/clang"
 OBJCXX="/opt/local/var/macports/build/_Volumes_Shared_macports-
 ports_archivers_zpaq/zpaq/work/compwrap/objcxx/usr/bin/clang++"
 CXXFLAGS="-Os
 -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk
 -stdlib=libc++" INSTALL="/usr/bin/install -c" CC+="-arch x86_64"
 CXXFLAGS+="-arch x86_64" OBJC+="-arch x86_64" OBJCXX+="-arch x86_64"
 LD+="-arch x86_64" F77+="-m64" F90+="-m64" FC+="-m64"
 CPP+="-DJUST_TESTING"
 }}}

 Looks like this is where the flags are being appended, in an unusual way,
 at the end of configure.args, and I don't understand the choice of
 variables. For example, the `-arch` flag is appended to CXXFLAGS, but not
 to CFLAGS nor LDFLAGS. It is appended to CC and LD but that doesn't make a
 great deal of sense to me. This Makefile doesn't use the LD variable. My
 `-DJUST_TESTING` addition is being appended not to CPPFLAGS but to CPP;
 this Makefile doesn't use the CPP variable.

 {{{
 make: Entering directory `/opt/local/var/macports/build
 /_Volumes_Shared_macports-ports_archivers_zpaq/zpaq/work/zpaq-7.15'
 /opt/local/var/macports/build/_Volumes_Shared_macports-
 ports_archivers_zpaq/zpaq/work/compwrap/cxx/usr/bin/clang++
 -I/opt/local/include
 -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -Dunix -Os
 -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk
 -stdlib=libc++ -arch x86_64 -o zpaq.o -c zpaq.cpp -pthread
 /opt/local/var/macports/build/_Volumes_Shared_macports-
 ports_archivers_zpaq/zpaq/work/compwrap/cxx/usr/bin/clang++
 -I/opt/local/include
 -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -Dunix -Os
 -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk
 -stdlib=libc++ -arch x86_64 -o libzpaq.o -c libzpaq.cpp
 /opt/local/var/macports/build/_Volumes_Shared_macports-
 ports_archivers_zpaq/zpaq/work/compwrap/cxx/usr/bin/clang++
 -L/opt/local/lib -Wl,-headerpad_max_install_names -stdlib=libc++
 -Wl,-syslibroot,/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -o
 zpaq zpaq.o libzpaq.o -pthread
 pod2man zpaq.pod >zpaq.1
 make: Leaving directory `/opt/local/var/macports/build
 /_Volumes_Shared_macports-ports_archivers_zpaq/zpaq/work/zpaq-7.15'
 }}}

 Note `-arch` flag missing from the link line. Link succeeded for this non-
 universal build since x86_64 is the default arch but link fails if I'm
 trying to build universal:

 {{{
 /opt/local/var/macports/build/_Volumes_Shared_macports-
 ports_archivers_zpaq/zpaq/work/compwrap/cxx/usr/bin/clang++
 -L/opt/local/lib -Wl,-headerpad_max_install_names -stdlib=libc++
 -Wl,-syslibroot,/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -o
 zpaq zpaq.o libzpaq.o -pthread
 ld: warning: ignoring file zpaq.o, building for macOS-x86_64 but
 attempting to link with file built for unknown-arm64
 ld: warning: ignoring file libzpaq.o, building for macOS-x86_64 but
 attempting to link with file built for unknown-arm64
 Undefined symbols for architecture x86_64:
   "_main", referenced from:
      implicit entry/start for main executable
 ld: symbol(s) not found for architecture x86_64
 clang: error: linker command failed with exit code 1 (use -v to see
 invocation)
 make: *** [zpaq] Error 1
 }}}

 Looks like the reason why `-arch` flags are being added for CXXFLAGS is
 that I listed it in `makefile.override`. If I add LDFLAGS to
 `makefile.override` then `-arch` flags return for the link line, but that
 shouldn't be necessary. And I don't want to specify CPPFLAGS in
 `makefile.override` because I don't want to override the Makefile's
 CPPFLAGS.

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


More information about the macports-tickets mailing list