# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4 PortSystem 1.0 PortGroup legacysupport 1.1 legacysupport.newest_darwin_requires_legacy 16 name go epoch 3 # IMPORTANT: # # When updating major versions, please ensure that you have committed and # tested the candidate version using the `go-devel` port, to verify how it # builds against current and older versions of macOS. if {$subport eq $name} { # Go 1.22 does not build on macOS 10.12 and older. # 1.14.x is the last branch to support i386 on macOS. # However past 1.11.x everything is broken. # FIXME: consider implementing support for PowerPC. if {${os.platform} eq "darwin" && ${os.major} < 17} { if {${build_arch} eq "i386"} { version 1.11.13 revision 0 set unsupported_macos_386 true set unsupported_macos false } else { version 1.17.13 revision 0 set unsupported_macos true set unsupported_macos_386 false } } else { version 1.22.3 set unsupported_macos false set unsupported_macos_386 false revision 0 } platforms {darwin >= 10} freebsd linux } # Subport for Go Unstable Version subport ${name}-devel { version 1.22.3 revision 0 epoch 1 platforms {darwin >= 17} freebsd linux } if {${os.platform} eq "darwin" \ && (${os.major} < 11 || ${configure.build_arch} eq "i386")} { set legacy_build true } else { set legacy_build false } homepage https://go.dev categories lang license BSD description compiled, garbage-collected, concurrent programming \ language developed by Google Inc. long_description \ The Go programming language is an open source project to make programmers \ more productive. Go is expressive, concise, clean, and efficient. Its \ concurrency mechanisms make it easy to write programs that get the most \ out of multicore and networked machines, while its novel type system \ enables flexible and modular program construction. Go compiles quickly \ to machine code yet has the convenience of garbage collection and the \ power of run-time reflection. It's a fast, statically typed, compiled \ language that feels like a dynamically typed, interpreted language. Go \ is developed by Google Inc. set go_src_dist go${version}.src${extract.suffix} set go_armbin_dist go${version}.darwin-arm64${extract.suffix} set go_amdbin_dist go${version}.darwin-amd64${extract.suffix} livecheck.type regex livecheck.url ${homepage}/dl/ if {$subport eq "${name}-devel"} { # Go (DEVEL / UNSTABLE) checksums ${go_src_dist} \ rmd160 9a4a34d495d8a047b5c70f8b14274b9ba98cfe47 \ sha256 80648ef34f903193d72a59c0dff019f5f98ae0c9aa13ade0b0ecbff991a76f68 \ size 27552410 \ ${go_armbin_dist} \ rmd160 f57d324d651c6e06d7024efa30e55a3f6036f5cf \ sha256 02abeab3f4b8981232237ebd88f0a9bad933bc9621791cd7720a9ca29eacbe9d \ size 67299997 \ ${go_amdbin_dist} \ rmd160 246529b8d324ab2ffe310e67b0f541993370322f \ sha256 610e48c1df4d2f852de8bc2e7fd2dc1521aac216f0c0026625db12f67f192024 \ size 70325332 livecheck.regex {go([0-9.A-z]+)\.src\.tar\.gz} } else { # Go (RELEASE) if {${unsupported_macos_386}} { # 1.11 checksums ${go_src_dist} \ rmd160 19d71fb4c196bd5bb03cab40cc99b35f312aaefc \ sha256 5032095fd3f641cafcce164f551e5ae873785ce7b07ca7c143aecd18f7ba4076 \ size 21114296 notes-append " Please note: Go 1.22 does not build on macOS 10.6 and older, so Go ${version} has been installed. " } elseif {${unsupported_macos}} { # 1.17 checksums ${go_src_dist} \ rmd160 6d8a13da5112ee67bb886eca0fec77ffaab27a5f \ sha256 a1a48b23afb206f95e7bbaa9b898d965f90826f6f1d1fc0c1d784ada0cd300fd \ size 22206518 \ ${go_armbin_dist} \ rmd160 1e2b1b394f912d92c3afde177f657733692ff593 \ sha256 e4ccc9c082d91eaa0b866078b591fc97d24b91495f12deb3dd2d8eda4e55a6ea \ size 130528194 \ ${go_amdbin_dist} \ rmd160 5ff00c1089ca3143c2f8e489f82c659f1066a17a \ sha256 c101beaa232e0f448fab692dc036cd6b4677091ff89c4889cc8754b1b29c6608 \ size 137060546 notes-append " Please note: Go 1.22 does not build on macOS 10.12 and older, so Go ${version} has been installed. " } else { # 1.22 checksums ${go_src_dist} \ rmd160 9a4a34d495d8a047b5c70f8b14274b9ba98cfe47 \ sha256 80648ef34f903193d72a59c0dff019f5f98ae0c9aa13ade0b0ecbff991a76f68 \ size 27552410 \ ${go_armbin_dist} \ rmd160 f57d324d651c6e06d7024efa30e55a3f6036f5cf \ sha256 02abeab3f4b8981232237ebd88f0a9bad933bc9621791cd7720a9ca29eacbe9d \ size 67299997 \ ${go_amdbin_dist} \ rmd160 246529b8d324ab2ffe310e67b0f541993370322f \ sha256 610e48c1df4d2f852de8bc2e7fd2dc1521aac216f0c0026625db12f67f192024 \ size 70325332 } livecheck.regex {go([0-9.]+)\.src\.tar\.gz} } master_sites https://storage.googleapis.com/golang/ distfiles ${go_src_dist} worksrcdir ${name} maintainers {ciserlohn @ci42} \ {gmail.com:herby.gillot @herbygillot} \ openmaintainer extract.only ${go_src_dist} set GOROOT ${worksrcpath} set GOROOT_FINAL ${prefix}/lib/${subport} supported_archs arm64 i386 x86_64 switch ${configure.build_arch} { arm64 { set GOARCH arm64 } i386 { set GOARCH 386 } x86_64 { set GOARCH amd64 } default { set GOARCH {} } } use_configure no build.dir ${worksrcpath}/src build.cmd ./make.bash build.target build.env GOROOT=${GOROOT} \ GOARCH=${GOARCH} \ GOOS=darwin \ GOROOT_FINAL=${GOROOT_FINAL} \ CC=${configure.cc} # Set build.jobs to -1 to disable MacPorts from adding the -j flag for # parallel builds, since the build.cmd contains "make". build.jobs -1 if {${os.platform} eq "darwin" && ${os.major} <= ${legacysupport.newest_darwin_requires_legacy}} { # The legacy support PG will not actually change anything in this port directly, # since go doesn't use the standard CFLAGS/CXXFLAGS. # We need to patch the build system and set up env variables manually. if {[vercmp ${version} < 1.19] && !${legacy_build}} { # Older compilers don't support the -Wno-nullability-completeness flag and if # that's the case, they won't need it anyway, so just patch it out. # Upstream no longer uses the flag as of 1.19beta1. # https://github.com/golang/go/commit/bf19163a545c3117ab3c309a691f32a42cf29efd patchfiles-append patch-cgo-drop-no-nullability-completeness.diff } # Fix building with the -x flag ("show all commands as they are executed"), # useful for debugging of the bootstrapping process. # Only needed for debugging the build/bootstrapping process. # FIXME: report this as a bug and have it or a better version of it upstreamed. #patchfiles-append patch-go-internal-buildid-and-gc-fix-debug.diff # Show all commands while building packages and only build one package at a time in # the last bootstrapping step. # Only needed for debugging the build/bootstrapping process. #patchfiles-append patch-build-show-commands.diff build.env-append "GO_EXTLINK_ENABLED=1" \ "GO_LDFLAGS=\"-extldflags=${configure.ldflags}\"" \ "BOOT_GO_LDFLAGS=-extldflags=${configure.ldflags}" \ "CGO_LDFLAGS=-g -O2 ${configure.ldflags}" # Might be useful while debugging issues. build.args-append "-v=3" notes-append [subst { 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. }] } if {${os.platform} eq "darwin" && ${os.major} == 10} { if {${configure.build_arch} eq "x86_64"} { # The branch https://github.com/catap/go/tree/macos-10.6 patchfiles-append patch-macOS-10.6.diff } elseif {${configure.build_arch} eq "i386"} { patchfiles-append patch-1.11.13-for-10.6-i386.diff } } use_parallel_build no if {${configure.build_arch} eq "arm64"} { # Use a temporary installation of the binary ARM64 Go distribution to # build Go for ARM64 set go_bin_path ${workpath}/${subport}_prebuilt build.env-append GOROOT_BOOTSTRAP=${go_bin_path}/go distfiles-append ${go_armbin_dist} post-extract { xinstall -d ${go_bin_path} system -W ${go_bin_path} \ "${extract.cmd} ${extract.pre_args} ${distpath}/${go_armbin_dist} ${extract.post_args}" } } elseif {${configure.build_arch} eq "x86_64" && (${os.major} >= 21 || !${legacy_build})} { # Use a temporary installation of the binary AMD64 Go distribution to # build Go for AMD64 on macOS 12 since go-1.4 fails to build set go_bin_path ${workpath}/${subport}_prebuilt build.env-append GOROOT_BOOTSTRAP=${go_bin_path}/go distfiles-append ${go_amdbin_dist} post-extract { xinstall -d ${go_bin_path} system -W ${go_bin_path} \ "${extract.cmd} ${extract.pre_args} ${distpath}/${go_amdbin_dist} ${extract.post_args}" } } else { # https://trac.macports.org/ticket/69160 build.env-append GOROOT_BOOTSTRAP=${prefix}/lib/go-1.4 \ GOHOSTARCH=${GOARCH} depends_build-append port:go-1.4 } post-build { system "find ${worksrcpath} -type d -name .hg* -print0 | xargs -0 rm -rf" delete ${worksrcpath}/pkg/bootstrap } if {$subport eq "${name}-devel"} { set bin_suffix "-devel" notes " go-devel binaries are installed with a ${bin_suffix} suffix: - go${bin_suffix} - gofmt${bin_suffix} " } else { set bin_suffix "" } destroot { delete ${worksrcpath}/src/cmd/vendor/github.com/google/pprof/internal/binutils/testdata/malformed_macho set grfdir ${destroot}${GOROOT_FINAL} set docdir ${destroot}${prefix}/share/doc/${subport} xinstall -d ${grfdir} xinstall -d ${docdir} foreach f {api bin lib misc pkg src test VERSION} { copy ${worksrcpath}/${f} ${grfdir} } foreach f {go gofmt} { system -W ${destroot}${prefix}/bin/ "ln -s ../lib/${subport}/bin/$f ./${f}${bin_suffix}" } xinstall -m 0644 -W ${worksrcpath} \ CONTRIBUTING.md \ LICENSE \ README.md \ PATENTS \ VERSION \ ${docdir} if {!${legacy_build}} { xinstall -m 0644 -W ${worksrcpath} SECURITY.md ${docdir} } copy {*}[glob -directory ${worksrcpath}/doc *] ${docdir} if { [ file exists ${worksrcpath}/go.env ] } { copy ${worksrcpath}/go.env ${grfdir}/ } }