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

Build failure on Mac OS due to ld -no-pie #140

Closed
rachitnigam opened this issue Feb 1, 2023 · 4 comments · Fixed by #141
Closed

Build failure on Mac OS due to ld -no-pie #140

rachitnigam opened this issue Feb 1, 2023 · 4 comments · Fixed by #141

Comments

@rachitnigam
Copy link
Contributor

I'm trying to build XLS on Mac OS from source which pulls rules_hdl as a dependency and the build seems to fail with the following error:

ERROR: /private/var/tmp/b3261ecaf5b6ec09d8051d16006b13a8/external/com_icarus_iverilog/BUILD.bazel:351:10: Linking external/com_icarus_iverilog/ivl failed: (Exit 1): cc_wrapper.sh failed: error executing command (from target @com_icarus_iverilog//:ivl) external/llvm_toolchain/bin/cc_wrapper.sh @bazel-out/darwin-opt/bin/external/com_icarus_iverilog/ivl-2.params

Digging into it, it seems that ld on mac has the option -no_pie instead of -no-pie used here:
https://github.com/hdl/bazel_rules_hdl/blob/main/dependency_support/com_icarus_iverilog/bundled.BUILD.bazel#L375

I'm not super familiar with bazel but if there is an obvious fix, I can try to write up a PR

@rachitnigam rachitnigam changed the title Build failure on Mac OS Build failure on Mac OS due to ld -no-pie Feb 1, 2023
@QuantamHD
Copy link
Collaborator

This is actually a rather easy fix if you want to give it a try.

The select below already has options for darwin(MacOS) in a list. You would just need to move that flag into the list. The select chooses to return a the list based on which platform your on.

select({
        "@bazel_tools//src/conditions:darwin": ["-Wl,-export_dynamic", "-no_pie"],
        "//conditions:default": ["-Wl,--export-dynamic", "-no-pie"],
    }),

@rachitnigam
Copy link
Contributor Author

Sweet! On it. Is there no need for a "-Wl,-no_pie" inside the select?

@QuantamHD
Copy link
Collaborator

I suspect "-Wl,-no_pie" is required. I just didn't type it correctly

@rachitnigam
Copy link
Contributor Author

Updated the PR to use it!

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 a pull request may close this issue.

2 participants