[MacPorts] #68700: go @1.17.13_0 - Legacy Go Compiler Completely Broken on Lion and Mtn Lion

MacPorts noreply at macports.org
Wed Apr 17 13:24:41 UTC 2024


#68700: go @1.17.13_0 - Legacy Go Compiler Completely Broken on Lion and Mtn Lion
---------------------+------------------------------
  Reporter:  RobK88  |      Owner:  (none)
      Type:  defect  |     Status:  new
  Priority:  Normal  |  Milestone:
 Component:  ports   |    Version:  2.8.1
Resolution:          |   Keywords:  lion moutainlion
      Port:  go      |
---------------------+------------------------------

Comment (by RobK88):

 I think I found the problem.

 The notes to `go` state:


 {{{
 bash-3.2$ port notes go
 --->  go has the following notes:
   Please note: Go 1.22 does not build on macOS 10.12 and older, so Go
 1.17.13 has been installed.
   go had to be specially patched and built to work on your platform.

   It likely won't work out of the box when building other projects, so
 make sure change your environment to use the following
   variables:
     * GO_EXTLINK_ENABLED="1"
   to always force go to use the external gcc or clang linker and
     * GO_LDFLAGS="\"-extldflags=${configure.ldflags}\""
     * CGO_LDFLAGS="-g -O2 ${configure.ldflags}"
   to force-link any binary against the legacy support library. Use exactly
 the quoting provided here, even if it may look
   odd, or compilation will fail.

   Failure to do so will leave you unable to create binaries that use
 features not natively available on your system, either
   directly or through a go core dependency.
 }}}

 So in ports that use `go`,  one needs to set `build.env` appropriately.
 E.g. In the `totp-cli` portfile, one sees:

 {{{
 pre-build {
 #   Sierra and earlier
     if { ${os.platform} eq "darwin" && ${os.major} < 17 } {
         build.env-append    GO_EXTLINK_ENABLED="1" \
 GO_LDFLAGS="\"-extldflags=${configure.ldflags}\"" \
                             CGO_LDFLAGS="-g -O2 ${configure.ldflags}"
     }
 }
 }}}


 But when you do so, the `CGO_LDFLAGS` is NOT set appropriately.  One see
 `:debug:build CGO_LDFLAGS='"-g'`

 As a result, when building a port on Lion and Mtn Lion (and other legacy
 Mac OS X) systems, the build fails with:


 {{{
 clang: error: no such file or directory: '"-g'
 }}}


 Here is a portion of main.log after trying to build `totp-cli`.

 {{{
 :debug:build CGO_CFLAGS='-Os -arch x86_64'
 :debug:build CGO_CXXFLAGS='-Os -stdlib=libc++ -arch x86_64'
 :debug:build CGO_LDFLAGS='"-g'
 :debug:build CPATH='/opt/local/include'
 :debug:build CPLUS_INCLUDE_PATH='/opt/local/include/LegacySupport'
 :debug:build
 CXX='/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports
 .org_macports_release_tarballs_ports_security_totp-cli/totp-
 cli/work/compwrap/cxx/usr/bin/clang++'
 :debug:build C_INCLUDE_PATH='/opt/local/include/LegacySupport'
 :debug:build DEVELOPER_DIR='/Applications/Xcode.app/Contents/Developer'
 :debug:build F77=''
 :debug:build F90=''
 :debug:build FC=''
 :debug:build GO111MODULE='off'
 :debug:build GOARCH='amd64'
 :debug:build GOOS='darwin'
 :debug:build
 GOPATH='/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports
 .org_macports_release_tarballs_ports_security_totp-cli/totp-
 cli/work/gopath'
 :debug:build GOPROXY='off'
 :debug:build GO_EXTLINK_ENABLED='"1"'
 :debug:build GO_LDFLAGS='""-extldflags=-Wl,-headerpad_max_install_names
 -L/opt/local/lib -lMacportsLegacySupport""'
 :debug:build LIBRARY_PATH='/opt/local/lib'
 :debug:build MACOSX_DEPLOYMENT_TARGET='10.8'
 }}}

 Perhaps, `build-env` should be:

 {{{
 pre-build {
 #   Sierra and earlier
     if { ${os.platform} eq "darwin" && ${os.major} < 17 } {
         build.env-append    GO_EXTLINK_ENABLED="1" \
 GO_LDFLAGS="\"-extldflags=${configure.ldflags}\"" \
                             CGO_LDFLAGS="\"-g -O2 ${configure.ldflags}\""
     }
 }
 }}}

 If this works, the notes to `go` will need to be changed.  And other ports
 that rely on `go` will need to be updated so they can build on legacy Mac
 OS X systems.

-- 
Ticket URL: <https://trac.macports.org/ticket/68700#comment:19>
MacPorts <https://www.macports.org/>
Ports system for macOS


More information about the macports-tickets mailing list