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

[easy][antlir][oss] fix distro toolchain on oss #274

Closed
wants to merge 2 commits into from
Closed

Conversation

vmagro
Copy link
Contributor

@vmagro vmagro commented Jan 3, 2025

Summary:
The default code for this in the prelude
https://www.internalfb.com/code/fbsource/[d9e5d887126868e28dd50b8911721d351f73a38a]/fbcode/buck2/prelude/cxx/cxx_toolchain_macro_layer.bzl?lines=13-19
https://github.com/facebook/buck2/blob/main/prelude/cxx/cxx_toolchain_macro_layer.bzl#L13-L19
relies on config settings that do not exist in the opensource prelude

Test Plan: Export to PR

Differential Revision: D67799115

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jan 3, 2025
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D67799115

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D67799115

facebook-github-bot pushed a commit that referenced this pull request Jan 3, 2025
Summary:

The default code for this in the prelude
https://www.internalfb.com/code/fbsource/[d9e5d887126868e28dd50b8911721d351f73a38a]/fbcode/buck2/prelude/cxx/cxx_toolchain_macro_layer.bzl?lines=13-19
https://github.com/facebook/buck2/blob/main/prelude/cxx/cxx_toolchain_macro_layer.bzl#L13-L19
relies on config settings that do not exist in the opensource prelude

Test Plan: Export to PR

Reviewed By: sergeyfd

Differential Revision: D67799115
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D67799115

vmagro and others added 2 commits January 6, 2025 08:17
Summary:
The complicated part of `unshare_userns` involves two `fork()`s with logic in
between the `fork()` and `exec()` in the child process. This comes with a bunch
of rules, the most annoying being no safe way to allocate memory.

Previously, I tried to "enforce" this by making the Rust crate `#![no_std]`,
but in fbcode, `std` is always unconditionally added as a buck2 dependency, so
there was nothing preventing `std` from being used (and thus, lots of things
that can do dynamic memory allocations). `std` usage was accidentally
introduced in D67157487.

To prevent this from happening again, to properly enforce these constraints,
and to fix the OSS build, I am rewriting the post-`fork()` logic in C. This is
a direct translation of the Rust code, which was already very C-like do to the
low-level syscalls being done.

Test Plan:
```
❯ buck2 test fbcode//antlir/antlir2/features/user/tests: fbcode//antlir/antlir2/features/install/tests:
Buck UI: https://www.internalfb.com/buck2/db4a7f57-d8a5-41d5-861c-4508eb80410a
Test UI: https://www.internalfb.com/intern/testinfra/testrun/5910974770074096
Tests finished: Pass 39. Fail 0. Fatal 0. Skip 0. Build failure 0

❯ buck2 test -c antlir2.rootless=1 fbcode//antlir/antlir2/features/user/tests: fbcode//antlir/antlir2/features/install/tests:
Buck UI: https://www.internalfb.com/buck2/ad2d4e89-d6ab-435c-a0a5-519560f52a3b
Test UI: https://www.internalfb.com/intern/testinfra/testrun/3659174958492970
Tests finished: Pass 39. Fail 0. Fatal 0. Skip 0. Build failure 0
```

Differential Revision: D67803947
Summary:
Pull Request resolved: #274

The default code for this in the prelude
https://www.internalfb.com/code/fbsource/[d9e5d887126868e28dd50b8911721d351f73a38a]/fbcode/buck2/prelude/cxx/cxx_toolchain_macro_layer.bzl?lines=13-19
https://github.com/facebook/buck2/blob/main/prelude/cxx/cxx_toolchain_macro_layer.bzl#L13-L19
relies on config settings that do not exist in the opensource prelude

Test Plan: Export to PR

Reviewed By: sergeyfd

Differential Revision: D67799115
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D67799115

@facebook-github-bot
Copy link
Contributor

This pull request has been merged in 208b68c.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants