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

appsec: fix compilation errors due to CGO and libddwaf stripping #1261

Merged
merged 2 commits into from
Apr 27, 2022

Conversation

Hellzy
Copy link
Contributor

@Hellzy Hellzy commented Apr 27, 2022

  • Compilation would fail if CGO was disabled due to prototypes mismatch for waf.Context.TotalRuntime(). Changed the prototype.
  • Compilation would fail on latest MacOS Big Sur (12.3.1) because of the way libddwaf was stripped. Strip by hand using the darwin strip binary for now.

Also fixes: https://github.com/DataDog/appsec-go-test-app/actions/runs/2233105581

The stripping done by the automated script left us with an invalid
binary for darwin. Use the MacOS strip binary for now.
@Hellzy Hellzy added the appsec label Apr 27, 2022
@Hellzy Hellzy added this to the 1.39.0 milestone Apr 27, 2022
@Hellzy Hellzy self-assigned this Apr 27, 2022
Copy link
Member

@felixge felixge left a comment

Choose a reason for hiding this comment

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

Just tested this locally and it fixes my compilation issue on macOS 12.3.1:

on v1 branch:

$ go test ./ddtrace/tracer/
# gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer.test
/usr/local/Cellar/go/1.18/libexec/pkg/tool/darwin_amd64/link: running clang failed: exit status 1
ld: in /Users/felix.geisendoerfer/go/src/github.com/DataDog/dd-trace-go/internal/appsec/waf/lib/darwin-amd64/libddwaf.a(PowerWAFInterface.cpp.o), section __TEXT/__eh_frame address out of range for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

FAIL	gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer [build failed]
FAIL

on this branch:

go test ./ddtrace/tracer/
ok  	gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer	19.706s

@Hellzy Hellzy marked this pull request as ready for review April 27, 2022 13:14
@Hellzy Hellzy requested a review from a team as a code owner April 27, 2022 13:14
@Hellzy
Copy link
Contributor Author

Hellzy commented Apr 27, 2022

Just tested this locally and it fixes my compilation issue on macOS 12.3.1:

Awesome! Thanks for checking. @felixge would you be able to merge this?
Julio is not back yet and I can't approve my own PR 😅

@nsrip-dd nsrip-dd merged commit 346c6a8 into v1 Apr 27, 2022
@nsrip-dd nsrip-dd deleted the francois.mazeau/compilation-fixes branch April 27, 2022 15:17
Hellzy added a commit that referenced this pull request Apr 28, 2022
* internal/appsec/waf: fix compilation issue when CGO disabled

* internal/appsec/waf: rework libddwaf stripping for darwin

The stripping done by the automated script left us with an invalid
binary for darwin. Use the MacOS strip binary for now.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants