jamesmunns / irr-embedded-2018

Increasing Rust's Reach, Embedded Group, 2018
2 stars 0 forks source link

Add 'it compiles' tests #2

Closed v-thakkar closed 6 years ago

v-thakkar commented 6 years ago

We aim to add tests which can successfully compile on $TARGET for the bunch of crates like libcore etc. We aim to add these tests no later than July 29, 2018. [Rust 1.28 ship date: 2nd August, 2018].

sekineh commented 6 years ago

libcore can be compiled if x.py dist is succeed. I guess some crate is needed for this task.

sekineh commented 6 years ago

There are two use cases:

sekineh commented 6 years ago

I'm writing here because it's a most basic issue.

Here's my first attempt of run-make which doesn't succeeds:

Makefile snippet v1

run-make/thumb-none-cortex-m/Makefile:

# warning: copy and paste ruined tab char!
-include ../../run-make-fulldeps/tools.mk

ifeq ($(TARGET),thumbv7m-none-eabi)
all:
    env > env.txt
    rm -rf cortex-m
    $(CARGO) clone cortex-m --vers 0.5.0 && cd cortex-m
    $(CARGO) build --target $(TARGET)
else
all:
endif

log and env.txt:

At this attempt, I tried to mimic the following cargo use case:

Available Environment Variables

In env.txt included in the gist, you can see environment variables you can use. https://gist.github.com/sekineh/a9e56bb523b071619c9f2b98e5d24d2f#file-env-txt

sekineh commented 6 years ago

What cargo build performs for cortex-m:

(Caution: attempt on Win10 beta-msvc host)

(win 10; workaround "Failed to find tool. Is `ar` installed?" error by providing `env`)

$ cargo clean
$ env AR_thumbv7m-none-eabi=arm-none-eabi-ar cargo build --target thumbv7m-none-eabi -v 2>&1 | tee build_thumbv7m-none-eabi.txt
   Compiling cc v1.0.18
   Compiling vcell v0.1.0
   Compiling aligned v0.2.0
   Compiling bare-metal v0.2.0
     Running `rustc --crate-name cc 'C:\Users\sekineh\.cargo\registry\src\github.com-1ecc6299db9ec823\cc-1.0.18\src\lib.rs' --crate-type lib --emit=dep-info,link -C debuginfo=2 -C metadata=9126dee9eaeb69ac -C extra-filename=-9126dee9eaeb69ac --out-dir 'C:\Users\sekineh\src\cortex-m\target\debug\deps' -L 'dependency=C:\Users\sekineh\src\cortex-m\target\debug\deps' --cap-lints allow`
     Running `rustc --crate-name vcell 'C:\Users\sekineh\.cargo\registry\src\github.com-1ecc6299db9ec823\vcell-0.1.0\src\lib.rs' --crate-type lib --emit=dep-info,link -C debuginfo=2 -C metadata=855f0aa10a27024c -C extra-filename=-855f0aa10a27024c --out-dir 'C:\Users\sekineh\src\cortex-m\target\thumbv7m-none-eabi\debug\deps' --target thumbv7m-none-eabi -C ar=arm-none-eabi-ar -C linker=arm-none-eabi-gcc -L 'dependency=C:\Users\sekineh\src\cortex-m\target\thumbv7m-none-eabi\debug\deps' -L 'dependency=C:\Users\sekineh\src\cortex-m\target\debug\deps' --cap-lints allow`
     Running `rustc --crate-name aligned 'C:\Users\sekineh\.cargo\registry\src\github.com-1ecc6299db9ec823\aligned-0.2.0\src\lib.rs' --crate-type lib --emit=dep-info,link -C debuginfo=2 -C metadata=bc95f696e48c7520 -C extra-filename=-bc95f696e48c7520 --out-dir 'C:\Users\sekineh\src\cortex-m\target\thumbv7m-none-eabi\debug\deps' --target thumbv7m-none-eabi -C ar=arm-none-eabi-ar -C linker=arm-none-eabi-gcc -L 'dependency=C:\Users\sekineh\src\cortex-m\target\thumbv7m-none-eabi\debug\deps' -L 'dependency=C:\Users\sekineh\src\cortex-m\target\debug\deps' --cap-lints allow`
     Running `rustc --crate-name bare_metal 'C:\Users\sekineh\.cargo\registry\src\github.com-1ecc6299db9ec823\bare-metal-0.2.0\src\lib.rs' --crate-type lib --emit=dep-info,link -C debuginfo=2 -C metadata=78f17c947b880b5f -C extra-filename=-78f17c947b880b5f --out-dir 'C:\Users\sekineh\src\cortex-m\target\thumbv7m-none-eabi\debug\deps' --target thumbv7m-none-eabi -C ar=arm-none-eabi-ar -C linker=arm-none-eabi-gcc -L 'dependency=C:\Users\sekineh\src\cortex-m\target\thumbv7m-none-eabi\debug\deps' -L 'dependency=C:\Users\sekineh\src\cortex-m\target\debug\deps' --cap-lints allow`
   Compiling volatile-register v0.2.0
     Running `rustc --crate-name volatile_register 'C:\Users\sekineh\.cargo\registry\src\github.com-1ecc6299db9ec823\volatile-register-0.2.0\src\lib.rs' --crate-type lib --emit=dep-info,link -C debuginfo=2 -C metadata=709a9f73a0e4731c -C extra-filename=-709a9f73a0e4731c --out-dir 'C:\Users\sekineh\src\cortex-m\target\thumbv7m-none-eabi\debug\deps' --target thumbv7m-none-eabi -C ar=arm-none-eabi-ar -C linker=arm-none-eabi-gcc -L 'dependency=C:\Users\sekineh\src\cortex-m\target\thumbv7m-none-eabi\debug\deps' -L 'dependency=C:\Users\sekineh\src\cortex-m\target\debug\deps' --extern 'vcell=C:\Users\sekineh\src\cortex-m\target\thumbv7m-none-eabi\debug\deps\libvcell-855f0aa10a27024c.rlib' --cap-lints allow`
   Compiling cortex-m v0.5.2 (file:///C:/Users/sekineh/src/cortex-m)
     Running `rustc --crate-name build_script_build build.rs --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=a4a6f0362a5801fc -C extra-filename=-a4a6f0362a5801fc --out-dir 'C:\Users\sekineh\src\cortex-m\target\debug\build\cortex-m-a4a6f0362a5801fc' -C 'incremental=C:\Users\sekineh\src\cortex-m\target\debug\incremental' -L 'dependency=C:\Users\sekineh\src\cortex-m\target\debug\deps' --extern 'cc=C:\Users\sekineh\src\cortex-m\target\debug\deps\libcc-9126dee9eaeb69ac.rlib'`
     Running `C:\Users\sekineh\src\cortex-m\target\debug\build\cortex-m-a4a6f0362a5801fc\build-script-build`
     Running `rustc --crate-name cortex_m 'src\lib.rs' --crate-type lib --emit=dep-info,link -C debuginfo=2 -C metadata=4556fb5e068fee24 -C extra-filename=-4556fb5e068fee24 --out-dir 'C:\Users\sekineh\src\cortex-m\target\thumbv7m-none-eabi\debug\deps' --target thumbv7m-none-eabi -C ar=arm-none-eabi-ar -C linker=arm-none-eabi-gcc -C 'incremental=C:\Users\sekineh\src\cortex-m\target\thumbv7m-none-eabi\debug\incremental' -L 'dependency=C:\Users\sekineh\src\cortex-m\target\thumbv7m-none-eabi\debug\deps' -L 'dependency=C:\Users\sekineh\src\cortex-m\target\debug\deps' --extern 'aligned=C:\Users\sekineh\src\cortex-m\target\thumbv7m-none-eabi\debug\deps\libaligned-bc95f696e48c7520.rlib' --extern 'bare_metal=C:\Users\sekineh\src\cortex-m\target\thumbv7m-none-eabi\debug\deps\libbare_metal-78f17c947b880b5f.rlib' --extern 'volatile_register=C:\Users\sekineh\src\cortex-m\target\thumbv7m-none-eabi\debug\deps\libvolatile_register-709a9f73a0e4731c.rlib' -L 'native=C:\Users\sekineh\src\cortex-m\target\thumbv7m-none-eabi\debug\build\cortex-m-7198b41ea6872672\out' --cfg cortex_m --cfg armv7m -l static=asm`
    Finished dev [unoptimized + debuginfo] target(s) in 3.77s

It's a library crate which is only suitable for it compiles test.

jamesmunns commented 6 years ago

Awesome job @sekineh! Am I understanding correctly that you were able to build the cortex-m crate as a run-make test?

Do you have your code pushed on github somewhere that I could look at?

sekineh commented 6 years ago

Not yet!

The above run is obtained on my local win10 PC using beta-msvc toolchain. I’m now at day job where win10 is main PC. The cargo error I workaround is not the same as the error that made run-make fail.

Other useful info:

sekineh commented 6 years ago

Makefile Tips 1) Or logic

We might want to change the ifeq line to use logical or of 4 targets.

ifeq ($(TARGET),thumbv7m-none-eabi)

To do that, see:

sekineh commented 6 years ago

Makefile Tips 2) Failable commands

By default make fails if one of the commands is failed. To ignore error, add '-' char in the begining of the command. Ex:

    -rm -rf cortex-m

See:

sekineh commented 6 years ago

@jamesmunns I have not created new branch yet. Currently, just experiments only.

sekineh commented 6 years ago

(Ubuntu) What cargo build performs for cortex-m:

We can use this as a reference

sekineh commented 6 years ago

Just opened the PR:

sekineh commented 6 years ago

This issue is closed by the successful merge of