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 linker for MacOS Ventura (13.0.1) #702

Merged
merged 5 commits into from
Dec 21, 2022
Merged

Add linker for MacOS Ventura (13.0.1) #702

merged 5 commits into from
Dec 21, 2022

Conversation

volsa
Copy link
Member

@volsa volsa commented Dec 19, 2022

No description provided.

riederm
riederm previously approved these changes Dec 19, 2022
src/linker.rs Outdated
// otherwise need to match against every exact e.g. MacOS version
None => match target_os {
"linux" | "gnu" => Box::new(LdLinker::new()),
"darwin22.1.0" => Box::new(CcLinker::new("clang")),
Copy link
Collaborator

Choose a reason for hiding this comment

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

The LD linker will work fine here and for now should be the default. Also if there's a way to avoid the version number it would be better maybe we can invert this Statement and only say windows does not get a linker. The idea was that Windows could not link using LD because we couldn't get it to accept all the correct settings at the time.

Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure why I didn't try LdLinker first but you're right, it's working :)
Anyways I don't have a Windows machine right now but can we assume target_os to always be windows or win32?

Copy link
Collaborator

Choose a reason for hiding this comment

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

windows and win32 are the only ones AFAIK

@@ -290,8 +290,10 @@ fn link_missing_file() {
fs::remove_file(&out).unwrap();
}

// TODO: Ghaith please fix this :)
Copy link
Collaborator

Choose a reason for hiding this comment

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

LD linker above should take care of this as far as I can tell

Copy link
Member Author

Choose a reason for hiding this comment

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

Getting the following errors:

ld: warning: ignoring file /var/folders/f8/6xt81h0n473gvtqsbsr70mf00000gn/T/.tmpZ6EOgj/cc_proj.so, building for macOS-arm64 but attempting to link with file built for unknown-unsupported file format ( 0x7F 0x45 0x4C 0x46 0x02 0x01 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 )

and

thread 'integration::linking::link_to_a_relative_location_with_no_parent' panicked at 'called `Result::unwrap()` on an `Err` value: GeneralError { message: "\nlld: error: /var/folders/f8/6xt81h0n473gvtqsbsr70mf00000gn/T/.tmplCmy1R/output.o: unknown file type\n", err_no: linker__generic_error }', tests/integration/linking.rs:323:6

Copy link
Member Author

Choose a reason for hiding this comment

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

Unrelated as we decided to use LD but when using clang the following error is yielded:

Undefined symbols for architecture arm64:
  "_main", referenced from:
     implicit entry/start for main executable
ld: symbol(s) not found for architecture arm64
clang-13: error: linker command failed with exit code 1 (use -v to see invocation)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ok, i'll take a look soon.

The LD linker is not supposed to be able to generate an executable unless you have a correct entry point.
The current advantage of of the LD linker is that it's built in/ embedded while clang is not.
Clang is however a compiler driver and thus makes it easier to run on different plafroms and to generate executables.
The error you are getting seems to be some missing libs in clang, not sure how that happened however.
For LD i think it compiled for the wrong target, is there a target in the test?

Copy link
Member Author

Choose a reason for hiding this comment

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

For LD i think it compiled for the wrong target, is there a target in the test?

Yes, there's a global TARGET variable but it's not used for that specific test.

@volsa
Copy link
Member Author

volsa commented Dec 19, 2022

Also do we want to remove this hardcoded line or should we leave it for now?

rusty/src/linker.rs

Lines 182 to 184 in be867c6

fn get_platform(&self) -> String {
"Linux".into()
}

@ghaith
Copy link
Collaborator

ghaith commented Dec 19, 2022

Also do we want to remove this hardcoded line or should we leave it for now?

rusty/src/linker.rs

Lines 182 to 184 in be867c6

fn get_platform(&self) -> String {
"Linux".into()
}

Yes we should not need this anymore i think

- Remove `get_platform()` function as it's not used outside the `linker` module
- Make linking possible for every platform but Windows, see also:
  https://github.com/PLC-lang/rusty/pull/702/files#r1052553988
@codecov-commenter
Copy link

codecov-commenter commented Dec 20, 2022

Codecov Report

Base: 94.41% // Head: 94.43% // Increases project coverage by +0.01% 🎉

Coverage data is based on head (4d59efd) compared to base (be867c6).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #702      +/-   ##
==========================================
+ Coverage   94.41%   94.43%   +0.01%     
==========================================
  Files          46       46              
  Lines       16228    16232       +4     
==========================================
+ Hits        15321    15328       +7     
+ Misses        907      904       -3     
Impacted Files Coverage Δ
src/linker.rs 81.69% <100.00%> (+2.50%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@volsa
Copy link
Member Author

volsa commented Dec 21, 2022

@ghaith would you be OK with the current solution, ignoring that one specific test for now? I'll see if I can fix this test in the coming days but merging this would be awesome because I could work on my MacBook without any local patching shenanigans :P

@ghaith
Copy link
Collaborator

ghaith commented Dec 21, 2022

Yes finde by me

@volsa volsa merged commit a51d5b4 into master Dec 21, 2022
@volsa volsa deleted the macos branch December 21, 2022 10:54
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.

4 participants