Skip to content

dym: fix zig cross compilation - #44656

Merged
mathetake merged 4 commits into
envoyproxy:mainfrom
ovadiagal:govadia/fix-zig-linker-flag
Apr 27, 2026
Merged

dym: fix zig cross compilation#44656
mathetake merged 4 commits into
envoyproxy:mainfrom
ovadiagal:govadia/fix-zig-linker-flag

Conversation

@ovadiagal

@ovadiagal ovadiagal commented Apr 24, 2026

Copy link
Copy Markdown
Contributor

The directive #cgo linux LDFLAGS: -Wl,--unresolved-symbols=ignore-all passes the --unresolved-symbols=ignore-all flag to the linker when compiling Go dynamic modules.

This flag is not supported in zig: ziglang/zig#21007.

When trying to bump dynamic-modules-examples to v1.38.0:

------
23.81 error: unsupported linker arg: --unresolved-symbols
23.81 
------
Dockerfile:45
--------------------
  43 |     COPY ./go /build
  44 |     WORKDIR /build
  45 | >>> RUN CC="zig cc -target aarch64-linux-gnu" CXX="zig c++ -target aarch64-linux-gnu" CGO_ENABLED=1 GOARCH=arm64 go build -buildmode=c-shared -o /build/arm64_libgo_module.so .
  46 |     RUN CC="zig cc -target x86_64-linux-gnu" CXX="zig c++ -target x86_64-linux-gnu" CGO_ENABLED=1 GOARCH=amd64 go build -buildmode=c-shared -o /build/amd64_libgo_module.so .
  47 |     
--------------------

Commit Message: dym: fix zig cross compilation
Additional Description:
Risk Level: Low
Testing: N/A
Docs Changes: N/A
Release Notes: N/A
Platform Specific Features:
[Optional Runtime guard:]
[Optional Fixes #Issue]
[Optional Fixes commit #PR or SHA]
[Optional Deprecated:]
[Optional API Considerations:]

@repokitteh-read-only

Copy link
Copy Markdown

As a reminder, PRs marked as draft will not be automatically assigned reviewers,
or be handled by maintainer-oncall triage.

Please mark your PR as ready when you want it to be reviewed!

🐱

Caused by: #44656 was opened by ovadiagal.

see: more, trace.

Signed-off-by: Gal Ovadia <ggalovadia@gmail.com>
Signed-off-by: Gal Ovadia <ggalovadia@gmail.com>
Signed-off-by: Gal Ovadia <ggalovadia@gmail.com>
@ovadiagal
ovadiagal force-pushed the govadia/fix-zig-linker-flag branch from 34c2854 to 04c9a8c Compare April 24, 2026 20:26
@ovadiagal
ovadiagal marked this pull request as ready for review April 24, 2026 20:27
/*
#cgo darwin LDFLAGS: -Wl,-undefined,dynamic_lookup
#cgo linux LDFLAGS: -Wl,--unresolved-symbols=ignore-all
#cgo linux,!zigcc LDFLAGS: -Wl,--unresolved-symbols=ignore-all

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the alternative i think is to instead make this opt in

Suggested change
#cgo linux,!zigcc LDFLAGS: -Wl,--unresolved-symbols=ignore-all
#cgo linux,gnuld LDFLAGS: -Wl,--unresolved-symbols=ignore-all

lmk what u think

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm. is the issue specific non gnuld is what you are saying? that's weird though !zigcc feels also weird...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm i think we can drop the linux LDFLAGS in the first place I think? the linker flag is only necessary for macos i believe.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(that's why it's been working before v1.38)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated to drop the entire line

@agrawroh

Copy link
Copy Markdown
Member

@mathetake Could you please take a look at this one?

Signed-off-by: ovadiagal <102482702+ovadiagal@users.noreply.github.com>
@mathetake
mathetake merged commit 3c9f5fc into envoyproxy:main Apr 27, 2026
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants