# -*- 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.23.5 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.24rc2 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 e32be298130c08f7d6c68f7f2e7c1d59e34a426d \ sha256 ba07b6863f208160e8f09f11c8b9582729b51cfeb752ce6ba79a379b4fbcac6d \ size 30043161 \ ${go_armbin_dist} \ rmd160 753bb8bc7aa9848f40c6b5d82c78de064f3b101a \ sha256 66c0299808cb02555031f6bf0a9bb9d57419178c4d182caebee126e53d906a58 \ size 75458927 \ ${go_amdbin_dist} \ rmd160 1c94cb01e44fc994a23bc5139f0dc230dc1e931c \ sha256 52e4be7607e6de43379b9161cc313bd5042b669e16a68f90f88b8206d7d117a8 \ size 79141357 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.23 checksums ${go_src_dist} \ rmd160 39055d686d12f0bff481f20fa4695bc596bb4724 \ sha256 a6f3f4bbd3e6bdd626f79b668f212fbb5649daf75084fb79b678a0ae4d97423b \ size 28179014 \ ${go_armbin_dist} \ rmd160 4e0f0a1f4d7df6f6316cd28813e8974d1e205529 \ sha256 047bfce4fbd0da6426bd30cd19716b35a466b1c15a45525ce65b9824acb33285 \ size 71649277 \ ${go_amdbin_dist} \ rmd160 a3f20a06eb4253030634f52236d941e9a69eb764 \ sha256 d8b310b0b6bd6a630307579165cfac8a37571483c7d6804a10dd73bbefb0827f \ size 74976003 } 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 \ 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}/ } }