Skip to content

Add Linker Support For L4Re #54425

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

Closed
wants to merge 7 commits into from
Closed

Add Linker Support For L4Re #54425

wants to merge 7 commits into from

Conversation

humenda
Copy link
Contributor

@humenda humenda commented Sep 21, 2018

L4Re uses a linker script called l4-bender used within the L4Re build system to cross-compile (/link) to L4Re. This PR adds l4-bender as another linker variant to Rustc.

@rust-highfive
Copy link
Contributor

r? @davidtwco

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 21, 2018
@rust-highfive
Copy link
Contributor

The job x86_64-gnu-llvm-5.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.

[00:04:32] travis_fold:start:tidy
travis_time:start:tidy
tidy check
[00:04:32] tidy error: /checkout/src/librustc_codegen_llvm/back/linker.rs:1218: trailing whitespace
[00:04:32] tidy error: /checkout/src/librustc_codegen_llvm/back/linker.rs:1232: trailing whitespace
[00:04:34] some tidy checks failed
[00:04:34] 
[00:04:34] 
[00:04:34] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/tidy" "/checkout/src" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "--no-vendor" "--quiet"
[00:04:34] 
[00:04:34] 
[00:04:34] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
[00:04:34] Build completed unsuccessfully in 0:00:49
[00:04:34] Build completed unsuccessfully in 0:00:49
[00:04:34] make: *** [tidy] Error 1
[00:04:34] Makefile:79: recipe for target 'tidy' failed

The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:01c003d8
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
---
travis_time:end:047ab3fa:start=1537535545822976725,finish=1537535545829289459,duration=6312734
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:0a0fb95f
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb --batch -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:16fb6cee
travis_time:start:16fb6cee
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:04a410e0
$ dmesg | grep -i kill

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

Copy link
Member

@davidtwco davidtwco left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

This looks pretty good to me, I've got a question and a few minor nits.

L4Bender::split_cmd_args(&mut cmd, &l4_ld_opts);
}

L4Bender { cmd: cmd,
Copy link
Member

Choose a reason for hiding this comment

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

nit: could you format this so the indentation is more consistent with other parts of the code.

L4Bender {
    cmd,
    sess,
    hinted_static: false,
}

or

L4Bender { cmd, sess, hinted_static: false, }

@@ -12,17 +12,6 @@ use spec::{LinkArgs, LinkerFlavor, PanicStrategy, TargetOptions};
use std::default::Default;
//use std::process::Command;
Copy link
Member

Choose a reason for hiding this comment

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

nit: could you remove this commented import?


if let Ok(l4_ld_opts) = env::var("L4_LD_OPTIONS") {
L4Bender::split_cmd_args(&mut cmd, &l4_ld_opts);
}
Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason that the flags -C link-arg or -C link-args to rustc (in combination with RUSTFLAGS for use with cargo build, etc.) can't be used instead of introducing new environment variables and a function to split them?

@humenda
Copy link
Contributor Author

humenda commented Sep 21, 2018 via email

@davidtwco
Copy link
Member

I'm not sure how that works either. Otherwise, this LGTM but I'll ping @alexcrichton who is more familiar with this part of the code.

r? @alexcrichton

@humenda
Copy link
Contributor Author

humenda commented Sep 25, 2018

@davidtwco You were right. L4_LD_OPTIONS replicates -C link-arg. However,
the other variable is still mandatory, since I need a way to correctly position
the bender-specific arguments on the command-line.
Is it fine in this case to introduce one more environment variable for the L4Re
target?

@davidtwco
Copy link
Member

@humenda I'm not sure what the preferred approach here is. I've found an old post by @alexcrichton that suggests (to me) that we'd prefer to not support new environment variables or flags for this sort of thing. I'm not too sure though. Hopefully @alexcrichton would be able to elaborate more on a preferred approach here.

That all said, I've found a handful of older commits that (to my untrained eye) seem like they might be relevant or useful and could give you a way to do this without a new flag or env variable:

  • I think there is an unstable -Z pre-link-arg flag. I found this commit about it.
  • You could also try using -C linker="l4-bender --l4-specific-flag" -Z linker-flavour=l4-bender - I've seen similar referenced in this commit.

@alexcrichton
Copy link
Member

Ah yeah sorry I've been slow to get here, the PR looks mostly good! I agree that we should avoid new env vars if possible (additionally avoiding trying to shell parse flags if we can). It looks like it should be possible to avoid here though, right?

@humenda
Copy link
Contributor Author

humenda commented Sep 28, 2018 via email

@alexcrichton
Copy link
Member

Sorry for being slow to reply, but if linker arguments must be at the front, can't a shell script be used to make sure they're placed at the front?

Otherwise the "pre" in "pre link args" I think means they'll always be sufficiently at the front

@TimNN TimNN added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 9, 2018
@TimNN
Copy link
Contributor

TimNN commented Oct 16, 2018

Ping from triage @humenda: Some additional clarifications have been requested for your PR.

@humenda
Copy link
Contributor Author

humenda commented Oct 17, 2018

Passing pre-link-args and link-args seems not possible with Cargo command-line flags ATM. There is CARGO_RUST_FLAGS, but my flags contain spaces and hence this is not an alternative. I suppose we'll need new Cargo options before this PR can be merge, hence I'm closing it for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants