Skip to content

Add support for windows linker args#1670

Open
n1ght-hunter wants to merge 1 commit intowild-linker:mainfrom
n1ght-hunter:push-mmnvvqsnqxtl
Open

Add support for windows linker args#1670
n1ght-hunter wants to merge 1 commit intowild-linker:mainfrom
n1ght-hunter:push-mmnvvqsnqxtl

Conversation

@n1ght-hunter
Copy link

@n1ght-hunter n1ght-hunter commented Mar 9, 2026

Requires #1629 to be merged before this can.

This pr adds windows style flags to the args parsing.
It also moves linux flags to linux modules.
This introduces target-lexicon as a new dep. for parsing -target which follows the llvm target triple spec.

Questions to be answered.

  • do we want the new sub modules. args/linux and args/windows. i like having the modules.
  • should they be named after the os or the output type. i.e. switch linux to elf and windows to coff or pe
  • the args/consts needs more thought. these mainly apply to elf only so perhaps should move removed and consts moved into either args.rs or linux.rs
  • do we want to use target-lexicon types more heavily. currently they are mapped to local types i.e. target_lexicon::Architecture -> lib_wild::Architecture. these could be removed from lib_wild and just use target-lexicon but that would mean matching on Architecture will have to match for Architecture's not supported by wild

arch: default_target_arch(),
// Infrastructure
should_fork: true,
arch: const { Architecture::from_target_lexicon(target_lexicon::HOST.architecture) },
Copy link
Author

Choose a reason for hiding this comment

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

the default should probably be the build target architecture not the build host

Copy link
Member

Choose a reason for hiding this comment

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

I'd prefer not to have a separate file for consts. We don't do that kind of thing elsewhere. It's a bit like having a module called "traits". It looks like these constants are a mix of ELF-specific constants and constants that should just be in the top-level args module.

Copy link
Member

Choose a reason for hiding this comment

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

Github is showing the entire file as new, which means we can't see what has changed. I'd say either leave all the linux argument parsing in args.rs, or we could do a PR before this one where we just copy the file and don't edit it.

/// - `-m <emulation>` — overrides format to ELF when present
///
/// Priority: `-m` overrides format from `--target`. Architecture comes from `--target` only.
pub(crate) fn detect_target(args: &[String]) -> Result<DetectedTarget> {
Copy link
Member

Choose a reason for hiding this comment

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

I think the --target flag might be too much for this PR, especially since it's non-standard. I worry that the discussion might get bogged down. What about splitting that to a later PR and for this one just accepting --flavor gnu or --flavor link as the first argument like LLD does?

.long("APPCONTAINER")
.help("/APPCONTAINER - Specifies whether the app must run within an appcontainer process environment.")
.execute(|_, _| unimplemented_option("/APPCONTAINER"));
// /ARM64XFUNCTIONPADMINX64 - Specifies the minimum number of bytes of padding between x64 functions in ARM64X images. 17.8
Copy link
Member

Choose a reason for hiding this comment

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

The comments seem to duplicate the help text. Also, they seem to be copied from Microsoft. I suspect for copyright reasons, we need to come up with our own descriptions of each flag. For unimplemented flags, it'd be fine to have the help text just say "unimplemented" and we can fill in our own descriptions as we implement them.

r#"C:\Users\Samuel\AppData\Local\Temp\rustc7RL5Io\symbols.o"#,
"dummy.dummy.6cfbe55db138f4b-cgu.0.rcgu.o",
"dummy.3wxfnlvokcqcl6j45c8xeicgz.rcgu.o",
r#"C:\Users\Samuel\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib\libstd-efa6c7783284bd31.rlib"#,
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps edit these lines to make them a bit shorter.

@mati865 mati865 mentioned this pull request Mar 9, 2026
@n1ght-hunter
Copy link
Author

im pretty busy with work stuff but will get to this over the weekend

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