Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

__res_search@GLIBC_2.2.5 issues on glibc < 2.34 #14

Closed
malt3 opened this issue Mar 13, 2023 · 2 comments
Closed

__res_search@GLIBC_2.2.5 issues on glibc < 2.34 #14

malt3 opened this issue Mar 13, 2023 · 2 comments
Labels
contributor friendly Good for newcomers upstream this is caused by an upstream issue

Comments

@malt3
Copy link

malt3 commented Mar 13, 2023

Hey, I'm just creating this issue to document the current state and maybe keep everyone updated.

The definition of __res_search and other symbols has changed between glibc versions, leading to linking issues when using zig cc on glibc < 2.34 (amd64).

Known functions that need special handling:

  • fcnt64
  • dn_expad
  • res_search
  • res_query
  • res_nquery

The issue is this one:

I still see this issue with Go 1.20 and zig 0.11.0-dev.811+8ff9284c4.

(20:10:30) ERROR: /private/var/tmp/_bazel_thomas/d95eb470615df18f91feffc144a9a015/external/com_github_sourcegraph_sourcegraph/cmd/migrator/BUILD.bazel:16:10: GoLink external/com_github_sourcegraph_sourcegraph/cmd/migrator/migrator_/migrator failed: (Exit 1): sandbox-exec failed: error executing command 
  (cd /private/var/tmp/_bazel_thomas/d95eb470615df18f91feffc144a9a015/sandbox/darwin-sandbox/21777/execroot/sourcegraph_oss && \
  exec env - \
    CGO_ENABLED=1 \
    GOARCH=amd64 \
    GOOS=linux \
    GOPATH='' \
    GOROOT=bazel-out/darwin_arm64-fastbuild-ST-0b20c6396c42/bin/external/io_bazel_rules_go/stdlib_ \
    GOROOT_FINAL=GOROOT \
    PATH=external/zig_sdk/tools/x86_64-linux-gnu.2.28:/bin:/usr/bin \
    TMPDIR=/var/folders/ws/lyfqx2sn72v223fhz5kb77m40000gp/T/ \
  /usr/bin/sandbox-exec -f /private/var/tmp/_bazel_thomas/d95eb470615df18f91feffc144a9a015/sandbox/darwin-sandbox/21777/sandbox.sb /var/tmp/_bazel_thomas/install/730b09b9d9f2bfd30b4c0a074ba23835/process-wrapper '--timeout=0' '--kill_delay=15' '--stats=/private/var/tmp/_bazel_thomas/d95eb470615df18f91feffc144a9a015/sandbox/darwin-sandbox/21777/stats.out' bazel-out/darwin_arm64-opt-exec-2B5CBBC6-ST-625e526ca8a8/bin/external/go_sdk/builder_reset/builder '-param=bazel-out/darwin_arm64-fastbuild-ST-4a519fd6d3e4/bin/external/com_github_sourcegraph_sourcegraph/cmd/migrator/migrator_/migrator-0.params' -- -extld external/zig_sdk/tools/x86_64-linux-gnu.2.28/c++ '-buildid=redacted' -extldflags '-fno-lto -Wl,-S')
net(.text): relocation target __res_search@GLIBC_2.2.5 not defined
os/user(.text): relocation target memset not defined
os/user(.text): relocation target memcpy not defined
runtime/cgo(.text): relocation target memset not defined
link: error running subcommand external/go_sdk/pkg/tool/darwin_arm64/link: exit status 2

There are two attempted workarounds in bazel-zig-cc (7b0de33 and 8d1e1c9) that do not fully resolve this issue.

@motiejus also stated

We agreed with @andrewrk that we will change the offending headers in upsteam zig (add ifdefs on glibc version). To my latest knowledge, @sywhang is working on that.

My goal here is to document that the issue still exists and have a place to share updates.

Edit: Fix PR was opened 🎉

@motiejus
Copy link
Collaborator

motiejus commented Mar 13, 2023

Thanks for the update, we are aware of this, and aware that the workaround in bazel-zig-cc does not fully resolve the issue.

The fix is known but not yet implemented; @sywhang just didn't get to that yet (the Go 1.20 upgrade has been tough). If you are inclined to do some #ifdefs for a couple of functions in Zig upstream, you are welcome.

Here are the list of functions that need special handling that Uber currently works around internally:

  • fcnt64
  • dn_expad
  • res_search
  • res_query
  • res_nquery

The list is exhaustive of the functions that we do have workarounds for, but it is likely there are more offenders.

Related: ziglang/zig#9485

I will leave this issue open until this is solved upstream by either/or:

  • short-term: a header patch with an #ifdef(__GLIBC__, <...>) to Zig upstream.
  • long-term: universal-headers

@motiejus motiejus added contributor friendly Good for newcomers upstream this is caused by an upstream issue labels Mar 14, 2023
@motiejus
Copy link
Collaborator

Fixed with #30 (or at least we will know it's fixed after I bring all the unit tests and infrastructure to order).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor friendly Good for newcomers upstream this is caused by an upstream issue
Projects
None yet
Development

No branches or pull requests

2 participants