Skip to content

Add Linker Support For L4Re - #54425

Closed
humenda wants to merge 7 commits into
rust-lang:masterfrom
humenda:master
Closed

Add Linker Support For L4Re#54425
humenda wants to merge 7 commits into
rust-lang:masterfrom
humenda:master

Conversation

@humenda

@humenda humenda commented Sep 21, 2018

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
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)

@davidtwco davidtwco left a comment

Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
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, }

Comment thread src/librustc_target/spec/l4re_base.rs Outdated

Copy link
Copy Markdown
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?

Copy link
Copy Markdown
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

humenda commented Sep 21, 2018 via email

Copy link
Copy Markdown
Contributor Author

@davidtwco

Copy link
Copy Markdown
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

humenda commented Sep 25, 2018

Copy link
Copy Markdown
Contributor Author

@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
Copy Markdown
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
Copy Markdown
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

humenda commented Sep 28, 2018 via email

Copy link
Copy Markdown
Contributor Author

@alexcrichton

Copy link
Copy Markdown
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

TimNN commented Oct 16, 2018

Copy link
Copy Markdown
Contributor

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

@humenda

humenda commented Oct 17, 2018

Copy link
Copy Markdown
Contributor Author

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