Comments (7)
The patches are in LLVM as r315852, r315853.
from cortex-m-rt.
Can someone pull in llvm-mirror/llvm@e53e8bd and llvm-mirror/llvm@99dc03a into https://github.com/rust-lang/llvm? I'm not sure what the process is.
from cortex-m-rt.
You might also need llvm-mirror/llvm@f9f40b5 depending on where that repo has branched from.
from cortex-m-rt.
@whitequark I tried your LLVM changes (the 3 patches) locally but I couldn't get the function deduplication to work.
I replaced global_asm!
with plain function calls for the core exceptions as seen in this
branch but I still see function duplication:
08000008 <EXCEPTIONS>:
8000008: 08000487 stmdaeq r0, {r0, r1, r2, r7, sl}
800000c: 0800048d stmdaeq r0, {r0, r2, r3, r7, sl}
8000010: 08000493 stmdaeq r0, {r0, r1, r4, r7, sl}
8000014: 08000499 stmdaeq r0, {r0, r3, r4, r7, sl}
8000018: 0800049f stmdaeq r0, {r0, r1, r2, r3, r4, r7, sl}
...
800002c: 080004a5 stmdaeq r0, {r0, r2, r5, r7, sl}
...
8000038: 080004ab stmdaeq r0, {r0, r1, r3, r5, r7, sl}
800003c: 080004b1 stmdaeq r0, {r0, r4, r5, r7, sl}
(..)
08000486 <NMI>:
8000486: f000 f816 bl 80004b6 <DEFAULT_HANDLER>
800048a: defe udf #254 ; 0xfe
0800048c <HARD_FAULT>:
800048c: f000 f813 bl 80004b6 <DEFAULT_HANDLER>
8000490: defe udf #254 ; 0xfe
08000492 <MEM_MANAGE>:
8000492: f000 f810 bl 80004b6 <DEFAULT_HANDLER>
8000496: defe udf #254 ; 0xfe
08000498 <BUS_FAULT>:
8000498: f000 f80d bl 80004b6 <DEFAULT_HANDLER>
800049c: defe udf #254 ; 0xfe
0800049e <USAGE_FAULT>:
800049e: f000 f80a bl 80004b6 <DEFAULT_HANDLER>
80004a2: defe udf #254 ; 0xfe
080004a4 <SVCALL>:
80004a4: f000 f807 bl 80004b6 <DEFAULT_HANDLER>
80004a8: defe udf #254 ; 0xfe
080004aa <PENDSV>:
80004aa: f000 f804 bl 80004b6 <DEFAULT_HANDLER>
80004ae: defe udf #254 ; 0xfe
080004b0 <SYS_TICK>:
80004b0: f000 f801 bl 80004b6 <DEFAULT_HANDLER>
80004b4: defe udf #254 ; 0xfe
080004b6 <DEFAULT_HANDLER>:
80004b6: f3ef 8008 mrs r0, MSP
80004ba: f000 b801 b.w 80004c0 <cortex_m_rt::default_handler>
80004be: defe udf #254 ; 0xfe
080004c0 <cortex_m_rt::default_handler>:
80004c0: be00 bkpt 0x0000
80004c2: e7fe b.n 80004c2 <cortex_m_rt::default_handler+0x2>
Passing -C passes=mergefunc
to rustc
didn't help. I also tried asm!("b DEFAULT_HANDLER")
instead of a function call but the result was the same.
It's been a while since I looked into this so I may be doing something wrong.
P.S. I could be misremembering but I don't recall the exception handlers including an abort
instruction (udf 0xfe
) in their bodies; they were just a single branch (b
) instruction, I think.
from cortex-m-rt.
That's weird. Care to give me the .ll
?
from cortex-m-rt.
Ohh, I must have been doing something wrong when testing with -C passes=mergefunc
because I'm now getting an LLVM error when compiling the compiler-builtins crate or the patched cortex-m-rt (v0.3.6 compiles fine with mergefunc).
$ cat .cargo/config
[target.thumbv7m-none-eabi]
runner = 'arm-none-eabi-gdb'
rustflags = [
"-C", "link-arg=-Tlink.x",
"-C", "linker=arm-none-eabi-ld",
"-C", "passes=mergefunc", # <-
"-Z", "linker-flavor=ld",
]
[build]
target = "thumbv7m-none-eabi"
$ rustup default nightly
$ xargo build --release && echo OK
OK
$ rustup default stage1 # with your LLVM patches
$ cargo clean; xargo build --release -v
+ "rustc" "--print" "sysroot"
+ "rustc" "--print" "target-list"
+ "cargo" "build" "--release" "--manifest-path" "/tmp/xargo.zcyfvDsh5p8w/Cargo.toml" "--target" "thumbv7m-none-eabi" "-v" "-p" "core"
Compiling core v0.0.0 (file:///home/japaric/rust/lang/src/libcore)
Running `rustc --crate-name core /home/japaric/rust/lang/src/libcore/lib.rs --crate-type lib --emit=dep-info,link -C opt-level=3 -C debuginfo=2 -C metadata=93d0fd8cf485fc37 -C extra-filename=-93d0fd8cf485fc37 --out-dir /tmp/xargo.zcyfvDsh5p8w/target/thumbv7m-none-eabi/release/deps --target thumbv7m-none-eabi -L dependency=/tmp/xargo.zcyfvDsh5p8w/target/thumbv7m-none-eabi/release/deps -L dependency=/tmp/xargo.zcyfvDsh5p8w/target/release/deps -C link-arg=-Tlink.x -C linker=arm-none-eabi-ld -C passes=mergefunc -Z linker-flavor=ld --sysroot /home/japaric/.xargo -Z force-unstable-if-unmarked`
Finished release [optimized + debuginfo] target(s) in 12.22 secs
+ "cargo" "build" "--release" "--manifest-path" "/tmp/xargo.7ifZ0QMksUzT/Cargo.toml" "--target" "thumbv7m-none-eabi" "-v" "-p" "compiler_builtins"
Compiling compiler_builtins v0.1.0 (file:///home/japaric/rust/lang/src/libcompiler_builtins)
Running `rustc --crate-name build_script_build /home/japaric/rust/lang/src/libcompiler_builtins/build.rs --crate-type bin --emit=dep-info,link -C opt-level=3 -C debuginfo=2 --cfg 'feature="compiler-builtins"' --cfg 'feature="default"' --cfg 'feature="mem"' -C metadata=91f17aa6bbbd60f8 -C extra-filename=-91f17aa6bbbd60f8 --out-dir /tmp/xargo.7ifZ0QMksUzT/target/release/build/compiler_builtins-91f17aa6bbbd60f8 -L dependency=/tmp/xargo.7ifZ0QMksUzT/target/release/deps`
Running `/tmp/xargo.7ifZ0QMksUzT/target/release/build/compiler_builtins-91f17aa6bbbd60f8/build-script-build`
Running `rustc --crate-name compiler_builtins /home/japaric/rust/lang/src/libcompiler_builtins/src/lib.rs --crate-type lib --emit=dep-info,link -C opt-level=3 -C debuginfo=2 --cfg 'feature="compiler-builtins"' --cfg 'feature="default"' --cfg 'feature="mem"' -C metadata=8501aab9e9d5f9f2 -C extra-filename=-8501aab9e9d5f9f2 --out-dir /tmp/xargo.7ifZ0QMksUzT/target/thumbv7m-none-eabi/release/deps --target thumbv7m-none-eabi -L dependency=/tmp/xargo.7ifZ0QMksUzT/target/thumbv7m-none-eabi/release/deps -L dependency=/tmp/xargo.7ifZ0QMksUzT/target/release/deps -C link-arg=-Tlink.x -C linker=arm-none-eabi-ld -C passes=mergefunc -Z linker-flavor=ld --sysroot /home/japaric/.xargo -Z force-unstable-if-unmarked --cfg thumb`
LLVM ERROR: Unexpected anonymous function when writing summary
LLVM assertions are now disabled by default in rust-lang/rust as of last week so my build also has them disabled. Perhaps this would have produced a more helpful message with assertions enabled?
Here are the .ll files without -C passes=mergfunc
. They look pretty much the same except for the differences in hashes / mangling so probably mergefunc
is disabled in the --release
passes.
from cortex-m-rt.
We are no longer using global_asm!
(or any other unstable feature). Weak aliasing (of exception / interrupt handlers to the DefaultHandler
) is implemented using linker scripts.
from cortex-m-rt.
Related Issues (20)
- How to link exceptions to C handlers HOT 2
- "error: cortex-m-rt appears more than once in the dependency graph" HOT 9
- main() calling convention discrepancy HOT 1
- How to utilize CCM SRAM for uninit statics? HOT 4
- VTOR and initial stack for debuggers HOT 5
- undefined reference to `__sheap' HOT 10
- Forward-port Changelog entries for v0.6.x
- RAM initialization code violates pointer provenance HOT 4
- Per crate memory.x file in a workspace. HOT 2
- [feature request] possibility to include asm stub before __pre_init for MCU that starts with RAM disabled HOT 5
- SCB.ICSR is more than 8 bits HOT 1
- Different virtual and physical address for FLAH HOT 1
- Error compiling with rwpi relocation model. HOT 2
- Position Independent Code HOT 2
- Why the code in this repo isn't the same as in crate.io even if the version number is the same? HOT 1
- master branch is out of date relative to 0.6.14 release HOT 2
- Use the semver trick? HOT 3
- Multiple versions of cortex-m-rt result in cryptic error messages HOT 4
- How to prevent generation of 'extra' code for ISR HOT 2
- Using the hard float compiler `thumbv7em-none-eabihf` problematic HOT 29
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cortex-m-rt.