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

feat: Enable libc/libc++ linking to expose system headers #168

Merged
merged 6 commits into from
Dec 28, 2023

Conversation

aherrmann
Copy link
Owner

The Zig compiler ships with various versions of libc and libc++. However, it does not link against these libraries by default, and accordingly does not expose standard library headers for C imports by default. To enable the import of C standard library headers the compiler must be instructed to link against libc or libc++ as appropriate by passing the -lc or -lc++ options, or similar.

This is already possible with rules_zig as is by adding a cc_library target to the cdeps attribute that sets linkopts to include -lc or similar. This change adds helper targets to rules_zig for convenience and includes an e2e test for this use-case.

Closes #161

  • test: C standard library header include
  • Helper targets to enable libc/libc++ linking
  • Use helper targets in tests
  • Mention libc/libc++ helper targets in doc strings
  • Update generated files

@aherrmann aherrmann enabled auto-merge December 28, 2023 14:01
@aherrmann aherrmann merged commit 795bdea into main Dec 28, 2023
21 checks passed
@aherrmann aherrmann deleted the sys-header-deps branch December 28, 2023 14:09
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.

C sources cannot include standard library headers
1 participant