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

Rejigger cargo manifest and config #280

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ermo
Copy link
Member

@ermo ermo commented Jul 17, 2024

With these changes, just get-started works for me again on Fedora.

It turns out that it's better to only rely on [target.'cfg(...)'] patterns for rustflags, as if there's a [build] section w/rustflags, it'll ignore the [target] sections entirely.

This PR moves the build profiles and the target compiler settings to the ./.cargo/config.toml file.

@ermo ermo added type: bug Something isn't working. type: enhancement New feature or request labels Jul 17, 2024
@ermo ermo added this to the oxide-prealpha1 milestone Jul 17, 2024
@ermo ermo requested review from ikeycode and tarkah as code owners July 17, 2024 19:27
@ermo ermo force-pushed the rejigger-cargo-manifest-and-config branch 2 times, most recently from 120065a to df10ea9 Compare July 18, 2024 01:36
Cargo.toml Outdated
Comment on lines 57 to 78
[profile.release]
lto = "thin"

[profile.packaging]
inherits = "release"
lto = true
codegen-units = 1
opt-level = 3
# allow packaging system to do it
strip = "none"
debug = true

# We want people who use the onboarding steps to get a nice compromise
# between fast compilation and fast runtime, but with checks in place
# and full backtraces. Hyperfine tests shows opt-level = 1 to be a good
# compromise between compile speed and runtime speed.
[profile.onboarding]
inherits = "dev"
opt-level = 1
lto = "thin"
debug = true
strip = "none"
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this is a good idea. Cargo.toml is for project or workspace configuration, while config.toml is for cargo configuration. The intent is that someone can override the config.toml at build time and get a different set of behavior.

boulder/build.rs Outdated
Comment on lines 7 to 9
// only recompile when necessary
let top_level = PathBuf::from("..").canonicalize()?;
println!("cargo::rerun-if-changed={}/build.rs", top_level.display());
Copy link
Contributor

Choose a reason for hiding this comment

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

These lines were only necessary since you were using a symlink for build.rs previously. Cargo already by default considers changes within the directory being built to invalidate cache results, so this is unnecessary.

Comment on lines 55 to 30
# NB: os_release patterns need to be added to both target configs for this to
# work...
#
# The Solus toolchain supports zstd debug sections currently (Serpent doesn't)
[target.'cfg(any(os_release_id = "solus"))']
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be better to remove this and have build.rs emit rustflag configurations instead. I think your goal here is that these configuration options would take effect for compilation of all crates, but that's not actually going to work since project dependencies are built BEFORE execution of the build.rs of a given project/crate. Since link-args are only used at link-time putting them in build.rs is perfectly fine since boulder and moss are where the linking happens anyway.

@ermo ermo force-pushed the rejigger-cargo-manifest-and-config branch 2 times, most recently from f20065e to 5d320c1 Compare July 18, 2024 01:46
@ermo ermo marked this pull request as draft July 18, 2024 01:51
@ermo
Copy link
Member Author

ermo commented Jul 18, 2024

Converting to draft as this clearly needs more work.

@ermo ermo force-pushed the rejigger-cargo-manifest-and-config branch 2 times, most recently from 8d07839 to 1ca802b Compare July 18, 2024 09:55
The goal is enable us to add distro-toolchain specific compile time
options trivially, whilst still having reasonably conservative onboarding
defaults, such that users can successfully run `just get-started` on a
variety of distributions.

By setting os_release_id="(...)" in build.rs in boulder/ and moss/, we
can now add specific flags known to work on platforms where we control
the toolchain build-time options.

As of now, the logic is working well enough that compilation doesn't stop
working if you're not on Solus. The current solution is meant as starting
point for a potentially more refined future solution if necessary.

Tested on fedora 39 and Solus.

Signed-off-by: Rune Morling <[email protected]>
@ermo ermo force-pushed the rejigger-cargo-manifest-and-config branch from 1ca802b to 159201e Compare August 2, 2024 14:21
@CLAassistant
Copy link

CLAassistant commented Jan 17, 2025

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working. type: enhancement New feature or request
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

3 participants