-
Notifications
You must be signed in to change notification settings - Fork 328
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
Add daita
as a Cargo feature
#6202
base: wireguard-go-rs
Are you sure you want to change the base?
Conversation
855b560
to
b057211
Compare
9c4a3f2
to
f0c8b56
Compare
0e32556
to
3c78155
Compare
a59f282
to
1fbda5b
Compare
a900bcf
to
a832721
Compare
a832721
to
2f6dd7d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One big concern with making DAITA a feature is that you would not be able to use --all-features
(on platforms without DAITA) anymore. The DAITA feature would have to be enabled on Windows and Linux and disabled on other platforms, and it would be up to the developer to know which platforms have the feature, otherwise the app will not build.
It seems that features simply cannot be specified per platform, it is a fundamental limitation of cargo. You cannot specify which features exists or are enabled by default per platform. It is not possible to get around this using build.rs
either, as feature resolution is done before the build scripts are run. You can set cfg variables like we do with wireguard_go
in talpid-wireguard
, but this can't affect which features are enabled in dependencies.
I have thought a lot about how to get around this, but it may be the case that the only proper solution is to simply abandon this PR and keep the raw #[cfg(any(target_os = "windows", target_os = "linux"))]
gates, unfortunately.
daf0938
to
f14fd21
Compare
aa19a28
to
f743af9
Compare
f743af9
to
255fe1a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 64 of 64 files at r1, all commit messages.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @MarkusPettersson98)
mullvad-management-interface/build.rs
line 7 at r1 (raw file):
// Enable Daita by default on Linux and Windows. println!("cargo:rustc-check-cfg=cfg(daita)");
should be double :
s, i thought it would reject the single-color syntax since check-cfg is a newly added thing 🤔
mullvad-relay-selector/build.rs
line 5 at r1 (raw file):
// Enable Daita by default on Linux and Windows. println!("cargo:rustc-check-cfg=cfg(daita)");
scobido doubleido, etc
maybe do a search replace
talpid-wireguard/src/lib.rs
line 70 at r1 (raw file):
/// TODO: Document /// TODO: Rename
👁️ 👄 👁️
wireguard-go-rs/Cargo.lock
line 1 at r1 (raw file):
# This file is automatically @generated by Cargo.
wgrs is part of the workspace, this file should be deleted
wireguard-go-rs/libwg/wireguard-go
line 1 at r1 (raw file):
Subproject commit 1e3bc447c174e243df151cf668ba8eab36739ce0
I guess update this after the other PR is merged
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @hulthe)
mullvad-management-interface/build.rs
line 7 at r1 (raw file):
Previously, hulthe (Joakim Hulthe) wrote…
should be double
:
s, i thought it would reject the single-color syntax since check-cfg is a newly added thing 🤔
Done. That's a bit weird aye, but good catch!
mullvad-relay-selector/build.rs
line 5 at r1 (raw file):
Previously, hulthe (Joakim Hulthe) wrote…
scobido doubleido, etc
maybe do a search replace
Done.
talpid-wireguard/src/lib.rs
line 70 at r1 (raw file):
Previously, hulthe (Joakim Hulthe) wrote…
👁️ 👄 👁️
Lmao, reverting this
wireguard-go-rs/Cargo.lock
line 1 at r1 (raw file):
Previously, hulthe (Joakim Hulthe) wrote…
wgrs is part of the workspace, this file should be deleted
🤦
wireguard-go-rs/libwg/wireguard-go
line 1 at r1 (raw file):
Previously, hulthe (Joakim Hulthe) wrote…
I guess update this after the other PR is merged
Yup
13d49d4
to
a49697f
Compare
b13dcc3
to
09f121c
Compare
5de99c8
to
a4ddd61
Compare
Gate DAITA compilation on `"cargo::rustc-cfg=daita"` emitted in build files per platform.
Clean up import gated by non-existing `daita` feature
Distribute the app with `libwg.so` Embed absolute rpath for dev builds on platforms which dynamically links `libwg` Add WorkingDirectory key to plist file to load `libwg.so` correctly on macOS.
Align `build-apk.sh` with `build.sh`
9cafff3
to
fc9295f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 4 of 6 files at r2, 21 of 22 files at r3, 1 of 1 files at r5, all commit messages.
Reviewable status: all files reviewed, 9 unresolved discussions (waiting on @hulthe and @MarkusPettersson98)
mullvad-daemon/build.rs
line 40 at r5 (raw file):
} // when development, configure rpath to facilitate linking with libwg.so
"when development"?
wireguard-go-rs/build.rs
line 43 at r5 (raw file):
// NOTE: Link to libwg dynamically on all platforms. // // LTO breaks when statically linking to libwg & Go programs does not
Great that you documented this. Perhaps we could even be more specific about the double symbol issue, to make it easier for future devs to find other solutions.
wireguard-go-rs/build-wireguard-go.sh
line 51 at r5 (raw file):
function build_unix { # TODO: consider using `log_header` here
I left this comment, though it's a very inconsequential style issue. We should remove the comment or implement it.
wireguard-go-rs/build-wireguard-go.sh
line 97 at r5 (raw file):
go build -v -o "$BUILD_DIR/lib/$TARGET/libwg.so" -buildmode c-shared fi # Copy libwg to `OUT_DIR` so that we may refer to it via `OUT_DIR` in `build.rs`, which might be handy.
Do we need two copies of the object file? Is it not ok to just move it instead?
fc9295f
to
346ddac
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 66 of 67 files reviewed, 8 unresolved discussions (waiting on @hulthe and @Serock3)
mullvad-daemon/build.rs
line 40 at r5 (raw file):
Previously, Serock3 (Sebastian Holmin) wrote…
"when development"?
Done Updated the text
wireguard-go-rs/build.rs
line 43 at r5 (raw file):
Previously, Serock3 (Sebastian Holmin) wrote…
Great that you documented this. Perhaps we could even be more specific about the double symbol issue, to make it easier for future devs to find other solutions.
Done clarified that part 😊
wireguard-go-rs/build-wireguard-go.sh
line 51 at r5 (raw file):
Previously, Serock3 (Sebastian Holmin) wrote…
I left this comment, though it's a very inconsequential style issue. We should remove the comment or implement it.
Since the output most likely will be consumed by cargo
, and would seldom be seen by a human, I think it's fine to just not implement it here. At least for now 😊
wireguard-go-rs/build-wireguard-go.sh
line 97 at r5 (raw file):
Previously, Serock3 (Sebastian Holmin) wrote…
Do we need two copies of the object file? Is it not ok to just move it instead?
Kind of, yes. 😢 cargo
won't look outside of target
for stuff that we want to link against, which we let cargo
know about via the rustc-link-search
instruction. This is needed to do to make debug builds / cargo test
work as expected. However, OUT_DIR
changes between compilations, which means that rebuilding the project becomes kind of expensive (since we have to build wireguard-go
each time we hit cargo check/build/test
. Thus, it is cheaper to dump it into a known location build/lib/<arch>
and copy it from there to OUT_DIR
as needed.
This PR adds support for gating DAITA behind a cfg option. It also bundles
libwg
as a shared object, which unifies the process across platforms which use Wireguard-Go.This fixes DES-937.
This change is