Opened 2 years ago

Last modified 10 days ago

#64822 assigned defect

wireguard-go @0.0.20220117: Undefined symbols _clock_gettime _getentropy

Reported by: juhnhooo Owned by: cardi (calvin ardi)
Priority: Normal Milestone:
Component: ports Version: 2.7.2
Keywords: yosemite Cc: juhnhooo, ci42, herbygillot (Herby Gillot)
Port: wireguard-go

Description (last modified by ryandesign (Ryan Carsten Schmidt))

Hi

I use a MacBook Pro with Yosemite 10.10.5 and I want to install wireguard... so I install MacPorts-2.7.2-10.10-Yosemite and try sudo port install wireguard-go

But I get an error:

--->  Computing dependencies for wireguard-go
--->  Fetching archive for wireguard-go
--->  Attempting to fetch wireguard-go-0.0.20220117_0.darwin_14.x86_64.tbz2 from http://packages.macports.org/wireguard-go
--->  Attempting to fetch wireguard-go-0.0.20220117_0.darwin_14.x86_64.tbz2 from http://mse.uk.packages.macports.org/wireguard-go
--->  Attempting to fetch wireguard-go-0.0.20220117_0.darwin_14.x86_64.tbz2 from http://fra.de.packages.macports.org/wireguard-go
--->  Building wireguard-go
Error: Failed to build wireguard-go: command execution failed
Error: See /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_net_wireguard-go/wireguard-go/main.log for details.
Error: Follow https://guide.macports.org/#project.tickets if you believe there is a bug.
Error: Processing of port wireguard-go failed

The lastest lines are:

:info:build make: Entering directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_net_wireguard-go/wireguard-go/work/wireguard-go-0.0.20220117'
:info:build go build -v -o "wireguard-go"
:info:build # golang.zx2c4.com/wireguard
:info:build /opt/local/lib/go/pkg/tool/darwin_amd64/link: running /usr/bin/clang failed: exit status 1
:info:build Undefined symbols for architecture x86_64:
:info:build   "_clock_gettime", referenced from:
:info:build       _runtime.walltime_trampoline.abi0 in go.o
:info:build   "_getentropy", referenced from:
:info:build       _internal/syscall/unix.libc_getentropy_trampoline.abi0 in go.o
:info:build ld: symbol(s) not found for architecture x86_64
:info:build clang: error: linker command failed with exit code 1 (use -v to see invocation)
:info:build make[1]: *** [wireguard-go] Error 2
:info:build make: *** [generate-version-and-build] Error 2
:info:build make: Leaving directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_net_wireguard-go/wireguard-go/work/wireguard-go-0.0.20220117'
:info:build Command failed:  cd "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_net_wireguard-go/wireguard-go/work/wireguard-go-0.0.20220117" && /usr/bin/make -j1 -w 
:info:build Exit code: 2
:error:build Failed to build wireguard-go: command execution failed
:debug:build Error code: CHILDSTATUS 18993 2
:debug:build Backtrace: command execution failed
:debug:build     while executing
:debug:build "system {*}$notty {*}$callback {*}$nice $fullcmdstring"
:debug:build     invoked from within
:debug:build "command_exec -callback portprogress::target_progress_callback build"
:debug:build     (procedure "portbuild::build_main" line 8)
:debug:build     invoked from within
:debug:build "$procedure $targetname"
:error:build See /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_net_wireguard-go/wireguard-go/main.log for details.

Can you help me?

Thanks for all

Juhn_Hoo

Change History (6)

comment:1 Changed 2 years ago by ryandesign (Ryan Carsten Schmidt)

Cc: ci42 herbygillot added
Description: modified (diff)
Keywords: yosemite added; wireguard-go removed
Owner: set to cardi
Port: wireguard-go added
Status: newassigned
Summary: How to install wireguard-go on Mac OSX Yosemite 10.10.5wireguard-go @0.0.20220117: Undefined symbols _clock_gettime _getentropy

clock_gettime was new in OS X 10.11. MacPorts has a compatibility implementation of clock_gettime which ports can opt in to receiving by including the legacysupport portgroup which I see that the wireguard-go port does not do.

I'm not sure if the same applies to getentropy.

This port uses the go language, which could complicate matters. The problem may be in the go port rather than in the wireguard-go port. Cc'ing go's maintainers for input.

Last edited 2 years ago by ryandesign (Ryan Carsten Schmidt) (previous) (diff)

comment:2 Changed 2 years ago by snowflake (Dave Evans)

I'm running macOS 10.11.6 (sdk 10.12) with go @1.17.9_0

The simplest hello world program from https://go.dev/doc/tutorial/getting-started.html does not build and gives a clock_gettime error.

The Portfile does include legacysupport, but for some reason it is not working.

/opt/local/lib/go/pkg/tool/darwin_amd64/link: running /usr/bin/clang failed: exit status 1
Undefined symbols for architecture x86_64:
  "_clock_gettime", referenced from:
      _runtime.walltime_trampoline.abi0 in go.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

comment:4 Changed 2 years ago by snowflake (Dave Evans)

I've taken the advice in "port notes go" and put the environment text into my profile.

All I get when I run the profile is "bad substitution"

Here's the text of the port note:

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.

configure.ldflags is not set anywhere in the Portfile. What exactly should I put in my profile?

comment:5 Changed 2 years ago by kencu (Ken)

It is going to take some trial and error, but think of it this way: outside macports, go has a 0% chance of ever working on your system!

Once you do figure it out, the next one will be easier. Maybe grep the ports tree for some other port that uses these commands and see what they did in there.

I don't run 10.11 much, so I'm not going to be much help for you.

comment:6 Changed 10 days ago by RobK88

Make sure you add this to your portfile for your hello-world.go program.

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}"
    }
}
Note: See TracTickets for help on using tickets.