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 'it compiles' tests #2

Closed
v-thakkar opened this issue Jul 9, 2018 · 12 comments
Closed

Add 'it compiles' tests #2

v-thakkar opened this issue Jul 9, 2018 · 12 comments

Comments

@v-thakkar
Copy link
Collaborator

v-thakkar commented Jul 9, 2018

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].

@v-thakkar v-thakkar changed the title Add 'it compiles' test Add 'it compiles' tests Jul 9, 2018
@sekineh
Copy link
Collaborator

sekineh commented Jul 20, 2018

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

@sekineh
Copy link
Collaborator

sekineh commented Jul 23, 2018

There are two use cases:

  • use rustc directly
  • use cargo

@sekineh
Copy link
Collaborator

sekineh commented Jul 23, 2018

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

  • $(CARGO) is available but it's stage0.
sekineh@sekineh-VirtualBox:~/rustme7$ grep CARGO src/test/run-make/thumb-none-cortex-m/env.txt 
CARGO=/home/sekineh/rustme7/build/x86_64-unknown-linux-gnu/stage0/bin/cargo
  • stage2 $(RUSTC) is available:
RUSTC=LD_LIBRARY_PATH="/home/sekineh/rustme7/build/x86_64-unknown-linux-gnu/test/run-make/thumb-none-cortex-m/thumb-none-cortex-m:/home/sekineh/rustme7/build/x86_64-unknown-linux-gnu/stage2/lib:/home/sekineh/rustme7/build/x86_64-unknown-linux-gnu/stage0-bootstrap-tools/x86_64-unknown-linux-gnu/release/deps:/home/sekineh/rustme7/build/x86_64-unknown-linux-gnu/stage0/lib:" '/home/sekineh/rustme7/build/x86_64-unknown-linux-gnu/stage2/bin/rustc' --out-dir /home/sekineh/rustme7/build/x86_64-unknown-linux-gnu/test/run-make/thumb-none-cortex-m/thumb-none-cortex-m -L /home/sekineh/rustme7/build/x86_64-unknown-linux-gnu/test/run-make/thumb-none-cortex-m/thumb-none-cortex-m  -Clinker=arm-none-eabi-gcc

@sekineh
Copy link
Collaborator

sekineh commented Jul 26, 2018

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

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

sekineh commented Jul 26, 2018

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:

  • cargo has -v and -vv option which displays commands internally run! -vv is better for coverage. We might be able to run equivalent commands individually if cargo attempt finally failed. (As a last resort)
  • There's no dry-run option :-(

@sekineh
Copy link
Collaborator

sekineh commented Jul 26, 2018

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

sekineh commented Jul 26, 2018

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

sekineh commented Jul 26, 2018

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

@sekineh
Copy link
Collaborator

sekineh commented Jul 27, 2018

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

We can use this as a reference

@sekineh
Copy link
Collaborator

sekineh commented Aug 8, 2018

@sekineh
Copy link
Collaborator

sekineh commented Sep 2, 2018

This issue is closed by the successful merge of

@sekineh sekineh closed this as completed Sep 2, 2018
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

No branches or pull requests

3 participants