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

Add daita as a custom config name #6202

Merged
merged 5 commits into from
Jun 11, 2024

Conversation

MarkusPettersson98
Copy link
Contributor

@MarkusPettersson98 MarkusPettersson98 commented Apr 30, 2024

This PR adds support for gating DAITA behind a cfg option. This makes it way easier to track what code is strictly DAITA-related, as well as enabling DAITA support on other platforms down the line.

This PR also changes the build chain of the app on Android, Linux and macOS.

  • On Linux and macOS, libwg is now distributed as a shared library, which is how wireguard-go currently is built for Android.
  • On all of the above platforms, wireguard-go is now a submodule in the app repository. This means that it has to be checkout out in order to build the app on these platforms. This has been detailed in the general build instructions.

This fixes DES-937.


This change is Reviewable

Copy link

linear bot commented Apr 30, 2024

@Serock3 Serock3 force-pushed the wireguard-go-rs branch 2 times, most recently from 855b560 to b057211 Compare May 2, 2024 11:23
@Serock3 Serock3 force-pushed the wireguard-go-rs branch from 2be229f to b3cf5d7 Compare May 6, 2024 09:55
@Serock3 Serock3 force-pushed the wireguard-go-rs branch from b3cf5d7 to 96c449f Compare May 6, 2024 11:29
@MarkusPettersson98 MarkusPettersson98 force-pushed the add-daita-cfg-flag branch 2 times, most recently from a59f282 to 1fbda5b Compare May 6, 2024 11:31
@MarkusPettersson98 MarkusPettersson98 requested a review from Serock3 May 6, 2024 12:44
@MarkusPettersson98 MarkusPettersson98 marked this pull request as ready for review May 6, 2024 13:32
@MarkusPettersson98 MarkusPettersson98 marked this pull request as draft May 6, 2024 13:32
@Serock3 Serock3 force-pushed the add-daita-cfg-flag branch from a900bcf to a832721 Compare May 6, 2024 20:38
@Serock3 Serock3 force-pushed the wireguard-go-rs branch from a0a1d67 to c1cf2db Compare May 6, 2024 20:48
@Serock3 Serock3 force-pushed the add-daita-cfg-flag branch from a832721 to 2f6dd7d Compare May 6, 2024 20:49
Copy link
Contributor

@Serock3 Serock3 left a 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.

@Serock3 Serock3 force-pushed the wireguard-go-rs branch from c1cf2db to 0d0f182 Compare May 8, 2024 14:06
@Serock3 Serock3 force-pushed the add-daita-cfg-flag branch from daf0938 to f14fd21 Compare May 8, 2024 14:32
@Serock3 Serock3 force-pushed the wireguard-go-rs branch from 0d0f182 to 80b9039 Compare May 14, 2024 07:50
@MarkusPettersson98 MarkusPettersson98 force-pushed the add-daita-cfg-flag branch 2 times, most recently from aa19a28 to f743af9 Compare May 17, 2024 14:42
Copy link
Contributor

@hulthe hulthe left a 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

Copy link
Contributor Author

@MarkusPettersson98 MarkusPettersson98 left a 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

@MarkusPettersson98 MarkusPettersson98 force-pushed the add-daita-cfg-flag branch 2 times, most recently from 13d49d4 to a49697f Compare May 29, 2024 14:29
@Serock3 Serock3 force-pushed the wireguard-go-rs branch 2 times, most recently from b13dcc3 to 09f121c Compare June 3, 2024 13:28
Copy link
Contributor

@Serock3 Serock3 left a comment

Choose a reason for hiding this comment

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

Reviewed 15 of 15 files at r7, 2 of 2 files at r8, all commit messages.
Reviewable status: all files reviewed, 6 unresolved discussions (waiting on @hulthe and @MarkusPettersson98)


ci/buildserver-build.sh line 166 at r7 (raw file):

    git checkout "$ref"
    git submodule update
    git submodule update --init --recursive --depth=1 wireguard-go-rs || true

What does the || true part do? My guess is that it swallows error non-zero exit codes. Would it not be equivalent to add a;?

@MarkusPettersson98 MarkusPettersson98 force-pushed the add-daita-cfg-flag branch 3 times, most recently from 885d8e0 to b9156cc Compare June 7, 2024 07:10
@MarkusPettersson98 MarkusPettersson98 force-pushed the wireguard-go-rs branch 4 times, most recently from 55cd5cd to df21d29 Compare June 7, 2024 13:40
@MarkusPettersson98 MarkusPettersson98 force-pushed the add-daita-cfg-flag branch 5 times, most recently from 7be0309 to 1a86a5c Compare June 10, 2024 08:31
@MarkusPettersson98 MarkusPettersson98 force-pushed the wireguard-go-rs branch 2 times, most recently from 8c62881 to ba7f8ca Compare June 10, 2024 11:48
@MarkusPettersson98 MarkusPettersson98 force-pushed the add-daita-cfg-flag branch 2 times, most recently from a9ac040 to 935e21f Compare June 10, 2024 12:19
Copy link
Contributor

@Serock3 Serock3 left a comment

Choose a reason for hiding this comment

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

Reviewed 20 of 20 files at r9, all commit messages.
Reviewable status: all files reviewed, 6 unresolved discussions (waiting on @hulthe and @MarkusPettersson98)

Copy link
Contributor

@Serock3 Serock3 left a 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, 7 unresolved discussions (waiting on @hulthe and @MarkusPettersson98)


talpid-wireguard/src/lib.rs line 825 at r9 (raw file):

    /// Configure and start a Wireguard-go tunnel.
    fn open_wireguard_go_tunnel(

Missing a #[cfg(wireguard_go)] here

Copy link
Contributor

@Serock3 Serock3 left a 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, 7 unresolved discussions (waiting on @hulthe and @MarkusPettersson98)


talpid-wireguard/src/lib.rs line 825 at r9 (raw file):

Previously, Serock3 (Sebastian Holmin) wrote…

Missing a #[cfg(wireguard_go)] here

Actually, this belongs to the other PR

Gate DAITA compilation on `"cargo::rustc-cfg=daita"` emitted in build
files per platform.
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`
Fix the build server scripts for Linux and Android by checking out the
wireguard-go submodule.
@MarkusPettersson98 MarkusPettersson98 merged commit 67fd997 into wireguard-go-rs Jun 11, 2024
54 of 56 checks passed
@MarkusPettersson98 MarkusPettersson98 deleted the add-daita-cfg-flag branch June 11, 2024 07:49
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.

3 participants