Opened 14 months ago
Last modified 12 months ago
#68340 new defect
go @1.17.13_0: environment variables for olders macOS versions cause bash to print "wrong substitution" and thus compiles fail.
Reported by: | garoffoli (garoffoli) | Owned by: | |
---|---|---|---|
Priority: | Normal | Milestone: | |
Component: | ports | Version: | |
Keywords: | Cc: | RobK88, tehcog (tehcog) | |
Port: | go |
Description
I've installed Go on my Mac running 10.9.5, after the install the follow message appears:
go has the following notes: Please note: Go 1.21 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.
However, when i copy the environment variables in .profiles. Bash throws up this error:
-bash: "-extldflags=${configure.ldflags}": wrong substitution -bash: -g -O2 ${configure.ldflags}: wrong substitution
And because of this, i can't even compile a simple Hello World executable. (I attached the build log)
Attachments (1)
Change History (11)
Changed 14 months ago by garoffoli (garoffoli)
Attachment: | buildlog.log added |
---|
comment:1 Changed 14 months ago by garoffoli (garoffoli)
Summary: | go @1.17.13_0: environmental variables for olders macOS versions cause bash to print "wrong substitution" and thus compiles fail. → go @1.17.13_0: environment variables for olders macOS versions cause bash to print "wrong substitution" and thus compiles fail. |
---|
comment:2 follow-up: 3 Changed 14 months ago by kencu (Ken)
the instructions don’t say it explicitly, but they are for Portfile additions, not for bash .profile additions.
comment:3 Changed 14 months ago by garoffoli (garoffoli)
Replying to kencu:
the instructions don’t say it explicitly, but they are for Portfile additions, not for bash .profile additions.
How I can do that? Try to set these variables using
go env -w CGO_LDFLAGS="-g -O2 ${configure.ldflags}"
still gives a wrong substitution error
comment:4 Changed 12 months ago by RobK88
@garoffoli - You will get a substitution error when running go env -w CGO_LDFLAGS="-g -O2 ${configure.ldflags}"
in bash since ${configure.ldflags}
is NOT defined in bash.
${configure.ldflags}
is defined in MacPorts. When you set CGO_LDFLAGS="-g -O2 ${configure.ldflags}"
in a Portfile, the environment variable will be set properly by MacPorts since Macports knows the value for ${configure.ldflags}
. Bash does not.
comment:5 Changed 12 months ago by RobK88
@garoffoli - Here is an example of setting these environment variables in a Portfile for a go
program. One would include this code block in the Portfile:
PortGroup legacysupport 1.1 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}" } }
Make sure you add the legacysupport 1.1
PortGroup.
comment:6 Changed 12 months ago by RobK88
I also have seen code written like this:
PortGroup legacysupport 1.1 legacysupport.newest_darwin_requires_legacy 16 pre-build { # Sierra and earlier if {${os.platform} eq "darwin" && ${os.major} <= ${legacysupport.newest_darwin_requires_legacy}} { build.env-append GO_EXTLINK_ENABLED="1" \ GO_LDFLAGS="\"-extldflags=${configure.ldflags}\"" \ CGO_LDFLAGS="-g -O2 ${configure.ldflags}" } }
comment:7 Changed 12 months ago by RobK88
Cc: | RobK88 added |
---|
comment:8 Changed 12 months ago by RobK88
P.S. The sample code above will not help you at this time. There is another problem! The legacy go
compiler, @1.7.13, that runs on Lion, Mtn Lion etc is now completely broken.
comment:9 Changed 12 months ago by tehcog (tehcog)
I haven't been able to get anything that uses 'go' to upgrade for quite some time now on Mavericks (exa: [66296 https://trac.macports.org/ticket/66296], fzf: [66295 https://trac.macports.org/ticket/66295]). Looks like the same may be becomming true with rust as well ([68719 https://trac.macports.org/ticket/68719]). I can understand google breaking everything as it is now to be expected, but Et tu, Rust? o_0
comment:10 Changed 12 months ago by tehcog (tehcog)
Cc: | tehcog added |
---|
Build Log