Tcl help ...

Christopher Jones jonesc at
Mon Mar 29 21:15:05 UTC 2021


> On 29 Mar 2021, at 9:40 pm, Joshua Root <jmr at> wrote:
> On 2021-3-30 06:35 , Christopher Jones wrote:
>> Hi All,
>> Working on fixing a build issue and hitting a limit in my current understanding of Tcl… I am trying to set some new env vars in the build.env
>>         set ldflags ${configure.ldflags}
>>         build.env-append   GO_EXTLINK_ENABLED=1
>>         build.env-append   GO_LDFLAGS='-extldflags\=$ldflags’
>> however, when the port in question using ${build.env} I get
>> DEBUG: system -W /opt/local/var/macports/build/_Users_chris_Projects_MacPorts_ports_devel_codesearch/codesearch/work/gopath/src/ <> GOPATH=/opt/local/var/macports/build/_Users_chris_Projects_MacPorts_ports_devel_codesearch/codesearch/work/gopath GOARCH=amd64 GOOS=darwin CC=/usr/bin/clang CXX=/usr/bin/clang++ GOPROXY=off GO111MODULE=off C_INCLUDE_PATH=/opt/local/include/LegacySupport OBJC_INCLUDE_PATH=/opt/local/include/LegacySupport CPLUS_INCLUDE_PATH=/opt/local/include/LegacySupport OBJCPLUS_INCLUDE_PATH=/opt/local/include/LegacySupport GO_EXTLINK_ENABLED=1 {GO_LDFLAGS='-extldflags=-L/opt/local/lib -Wl,-headerpad_max_install_names -lMacportsLegacySupport'} /opt/local/bin/go build cmd/cgrep/cgrep.go
>> sh: {GO_LDFLAGS=-extldflags=-L/opt/local/lib -Wl,-headerpad_max_install_names -lMacportsLegacySupport}:
> That isn't a result of setting build.env. You must have added this to build.args or similar.

I haven’t, but I think some ports do, see below.

>> See how the second env var I define above is shown inside {} braces, which of course sh cannot parse.
>> I have tried numerous forms of how to set
>> build.env-append   GO_LDFLAGS='-extldflags\=$ldflags’
>> but they all have the same issue.
>> I suspect this is just my lack of really undertanding quoting in tcl, so I am hoping someone can tell me what I am doing wrong ?
> Do you want literal single quotes in the value of the environment variable? If so:
> build.env-append   GO_LDFLAGS='-extldflags=${configure.ldflags}’
> if not:
> build.env-append   GO_LDFLAGS=-extldflags=${configure.ldflags}
> The value of the *.env options never gets passed to a shell; the environment variables are set directly by our code. The parsing is very simple, perhaps deceptively so if you expect it to work like a shell. Each list element is expected to contain a single assignment, with everything before the first '=' used as the variable name, and everything after it used as the value to set it to.

This is probably the problem, as there are a few ports that do pass it to a shell. see e.g. <>

All I have been trying to do is fix a few issues with go based builds, by adding some additional build env vars, on older systems, and I ran into the port above having problems. It appears to take build.env and directly pass it to a sell command, which from what you say should probably never be done. If thats the case I won’t worry about this one corner case port.

There are a handful of other ports that do something similar.


> A corollary is that something like this won't (in general) work:
> build.args-append ${build.env}
> because build.args has to deal with shell quoting. There's also a second bug in that line because it appends the entirety of build.env, which is a list, as a single element. The {*} operator is essential when doing something like this:
> build.args foo bar
> destroot.args-append {*}${build.args}
> - Josh

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 1930 bytes
Desc: not available
URL: <>

More information about the macports-dev mailing list