GithubHelp home page GithubHelp logo

thepowersgang / mrustc Goto Github PK

View Code? Open in Web Editor NEW
2.1K 45.0 105.0 18.54 MB

Alternative rust compiler (re-implementation)

License: MIT License

C++ 97.23% C 0.16% Makefile 0.91% Batchfile 0.24% Rust 1.06% Python 0.31% Shell 0.09%
rust-compiler compiler rust-language

mrustc's People

Contributors

aristarh2704 avatar arlied-google avatar arlosi avatar artoria2e5 avatar barbeque avatar barracuda156 avatar catap avatar coypoop avatar dkm avatar elichai avatar equal-l2 avatar est31 avatar evanmiller avatar fanquake avatar glaubitz avatar jirutka avatar justanotherstrange avatar lrvick avatar luke-jr avatar nabijaczleweli avatar notriddle avatar orowith2os avatar reitermarkus avatar rustacean-xyz avatar spacekookie avatar stikonas avatar thepowersgang avatar ubsan avatar valpackett avatar woachk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mrustc's Issues

Fails to build under aarch64 (ARM 64 bit)

Fails on the following step:

odroid@odroid64:~/mrustc$ "gcc" "-ffunction-sections" "-pthread" "-O2" "-g" "-o" "output/libcore.hir.o" "output/libcore.hir.o.c" "-c"
/tmp/ccFfliuA.s: Assembler messages:
/tmp/ccFfliuA.s:17954: Error: unknown mnemonic `pause' -- `pause'

which is caused by:

output/libcore.hir.o.c: __asm__ __volatile__("pause": : : "memory");

Any ideas how to work around?

Can't build trivial hello_world lib

I managed to build mrustc and minicargo, but I'm getting errors trying to use it to compile a trivial example. build_rustc_with_minicargo.sh completed successfully so mrustc must be functional. I tried adding the minicargo flags used in build_rustc_with_minicargo.sh, but that didn't help either.

$ bin/mrustc hello_world/src/lib.rs 
- Span: Empty span
Parse: V V V
(0.00 s) Parse: DONE
LoadCrates: V V V
:10: error:0:Unable to locate crate 'std'
Aborted (core dumped)
$ tools/bin/minicargo hello_world/
DEBUG: Start block package
DEBUG: package,name = "hello_world"
DEBUG: package,version = "0.1.0"
DEBUG: package,authors = ["Eitan Mosenkis <[email protected]>",]
DEBUG: Start block dependencies
DEBUG: - Implicit library
>>> load_dependencies(hello_world)
 DEBUG: Loading depencencies for hello_world
<<< load_dependencies
>>> add_dependencies(hello_world)
<<< add_dependencies
DEBUG: Building output/libhello_world.hir - Missing
Calling ../bin/mrustc hello_world/src/lib.rs --crate-name hello_world --crate-type rlib -o output/libhello_world.hir -L output
DEBUG: Compiler exited with non-zero exit status 127

Fails to build under armv7l

During make -f minicargo.mk, gcc complains about __int128 not being supported when compiling libcore.hir.o.c.

tagged_union assertion failures (FreeBSD 12 / clang 6)

> /usr/home/greg/src/github.com/thepowersgang/mrustc/bin/mrustc rustc-1.19.0-src/src/librustc_trans/lib.rs --crate-name rustc_trans --crate-type rlib -g --cfg debug_assertions -O -o output/rustc-build/librustc_trans.hir -L output/rustc-build --extern flate=output/rustc-build/libflate.hir --extern log=output/rustc-build/liblog-0_3_7.hir --extern owning_ref=output/rustc-build/libowning_ref-0_3_3.hir --extern rustc=output/rustc-build/librustc.hir --extern rustc_back=output/rustc-build/librustc_back.hir --extern rustc_bitflags=output/rustc-build/librustc_bitflags.hir --extern rustc_const_math=output/rustc-build/librustc_const_math.hir --extern rustc_data_structures=output/rustc-build/librustc_data_structures.hir --extern rustc_errors=output/rustc-build/librustc_errors.hir --extern rustc_incremental=output/rustc-build/librustc_incremental.hir --extern rustc_llvm=output/rustc-build/librustc_llvm.hir --extern rustc_platform_intrinsics=output/rustc-build/librustc_platform_intrinsics.hir --extern serialize=output/rustc-build/libserialize.hir --extern syntax=output/rustc-build/libsyntax.hir --extern syntax_pos=output/rustc-build/libsyntax_pos.hir -L output
Assertion failed: (!"ERROR: destructed tagged union used"), function equate_types_shadow, file src/hir_typeck/expr_cs.cpp, line 4025.
> /usr/home/greg/src/github.com/thepowersgang/mrustc/bin/mrustc rustc-1.19.0-src/src/librustc_trans/lib.rs --crate-name rustc_trans --crate-type rlib -g --cfg debug_assertions -O -o output/rustc-build/librustc_trans.hir -L output/rustc-build --extern flate=output/rustc-build/libflate.hir --extern log=output/rustc-build/liblog-0_3_7.hir --extern owning_ref=output/rustc-build/libowning_ref-0_3_3.hir --extern rustc=output/rustc-build/librustc.hir --extern rustc_back=output/rustc-build/librustc_back.hir --extern rustc_bitflags=output/rustc-build/librustc_bitflags.hir --extern rustc_const_math=output/rustc-build/librustc_const_math.hir --extern rustc_data_structures=output/rustc-build/librustc_data_structures.hir --extern rustc_errors=output/rustc-build/librustc_errors.hir --extern rustc_incremental=output/rustc-build/librustc_incremental.hir --extern rustc_llvm=output/rustc-build/librustc_llvm.hir --extern rustc_platform_intrinsics=output/rustc-build/librustc_platform_intrinsics.hir --extern serialize=output/rustc-build/libserialize.hir --extern syntax=output/rustc-build/libsyntax.hir --extern syntax_pos=output/rustc-build/libsyntax_pos.hir -L output
Assertion failed: (m_tag == TAG_Path), function as_Path, file src/hir/type.hpp, line 232.

After commenting out the assertions, a rustc was produced successfully.

Gcc6.1 has a compile errors

[pc@localhost mrustc]$ make
[CXX] -o .obj/ast/expr.o
src/ast/expr.cpp: In function ‘std::ostream& AST::operator<<(std::ostream&, const AST::ExprNode&)’:
src/ast/expr.cpp:44:5: error: nonnull argument ‘node’ compared to NULL [-Werror=nonnull-compare]
     if( static_cast<const void*>(&node) != nullptr ) {
     ^~
At global scope:
cc1plus: error: unrecognized command line option ‘-Wno-pessimizing-move’ [-Werror]
cc1plus: all warnings being treated as errors
make: *** [.obj/ast/expr.o] Error 1

2nd: (this happens all over the project, no idea what these empty if(0) are supposed to mean or do)

[CXX] -o .obj/hir/from_ast_expr.o
src/hir/from_ast_expr.cpp: In member function ‘virtual void LowerHIR_ExprNode_Visitor::visit(AST::ExprNode_BinOp&)’:
src/hir/from_ast_expr.cpp:158:90: error: this ‘if’ clause does not guard... [-Werror=misleading-indentation]
 AST::ExprNode_BinOp::CMPEQU :    op = ::HIR::ExprNode_BinOp::Op::CmpEqu ; if(0)
                                                                           ^~

Error during compilation on Release Linux Mint 18.1 Serena 64-bit

When i run this command : make -f minicargo.mk
I got this error :
output/libstd.hir.o.c:49611:9: error: ‘_ZRK$aLfn_1_$Rs__ZN3std9panicking9PanicInfo_$T0_as__ZN4core3ops5FnMut$aL$T1_$Rs__ZN3std9panicking9PanicInfo$aR$aRcall_mut’ undeclared here (not in a function) (void*)_ZRK$aLfn_1_$Rs__ZN3std9panicking9PanicInfo_$T0_as__ZN4core3ops5FnMut$aL$T1_$Rs__ZN3std9panicking9PanicInfo$aR$aRcall_mut

My active rustup toolchain is : nightly-x86_64-unknown-linux-gnu (default) rustc 1.27.0-nightly (8ff4b4206 2018-05-08)

My OS and kernel : Linux RomMint 4.4.0-116-generic #140-Ubuntu SMP Mon Feb 12 21:23:04 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

Thank you for your help

Parse macro invocation in repeated $($:item)*

This is very similar to #55, still trying to get the libc crate to compile. The following is minimized from their use of cfg_if! and compiles with rustc 1.19.0 but not mrustc.

macro_rules! outer {
    ({ $($x:item)* }) => {}
}

outer! {
    {inner!{}}
}
libc/src/lib.rs:5: error:0:Expected token in match arm

Compiling llvm with multiple jobs

I was doing make output/rustc -j 8 to compile rustc. Then I saw that when building LLVM, only one core was utilized, even though I have 7 more.

Incompatible with bindgen bitfields/incorrect derive clone

If code such as the following (used by bindgen) is written:

#[repr(C)]
#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct __BindgenBitfieldUnit<Storage, Align>
where
    Storage: AsRef<[u8]> + AsMut<[u8]>,
{
    storage: Storage,
    align: [Align; 0],
}

Mrustc fails with the error Failed to find an impl of ::"core"::clone::Clone for [Align/*I:1*/; 0]. This fine in the official compiler, which inserts Clone bounds for type parameters where needed, which I assume is what is missing in mrustc.

EDIT: Actually this is not as simple as I thought, and the example above doesn't trigger the behaviour described, I'll update this issue if I can get a proper MWE.

EDIT2: Actually it does trigger the behaviour, I was just having some caching issues when testing it.

Incorrect codegen in librustc with GCC 5

Seen both with GCC v5.5.0 and v5.4.0 (Linux Mint 18), x86-64

GCC's code generation for a particular function in librustc leads to uninitialised data being or-ed into the tag of an Option which is then matched upon and will abort due to the tag being neither 0 or 1.

TODO: Obtain full details of which function causes the issue

Support use as a Rust->C transpiler

I'm interested in using mrustc to allow me to write code in Rust for a platform not supported by LLVM (ESP8266), then transpile it to C and call it from a shim written in C/C++. I tried using mrustc on a trivial library and discovered that, even with #[no_mangle], the resulting C function did not retain its original Rust name.

Other features that would be helpful for this include an option to produce C output without compiling it and an option to use regular rustc to produce MIR and then transpile that to C.

I haven't tried using mrustc on Rust code that calls out to a C or C++ library, but if that's not supported already, it would be critical to my use case (e.g. writing Rust code on top of the ESP8266 Arduino library).

Thanks for your work on this project so far!

Encountered an unexpanded macro in type

The following compiles with rustc 1.19.0 but not mrustc. This is minimized from the syn crate.

macro_rules! m {
    ($tt:tt) => { $tt }
}

struct A;
struct B;

impl From<m!(A)> for B {
    fn from(_: A) -> B {
        unimplemented!()
    }
}
BUG:src/resolve/absolute.cpp:1525: Resolve_Absolute_Type - Encountered an unexpanded macro in type - m! /*{1} TT*//*{1}*/A

I tried it on a sample main.rs program

The output is always, even when i change some stuff in the rust file:

[pc@localhost mrustc]$ ./bin/mrustc main.rs
Parse: V V V
(0.00 s) Parse: DONE
LoadCrates: V V V
(0.00 s) LoadCrates: DONE
Expand: V V V
:0: BUG:src/expand/mod.cpp:849: TODO: Expand - Load libstd
Aborted (core dumped)
[pc@localhost mrustc]$

compilation issue: Unable to locate crate 'rustc_driver'

Hi,

Pretty cool project you have there. However, I seem to be running into different compilation errors, depending on how I run things.

In an isolated build container running (after putting rustc-1.19.0-src.tar.gz in the root directory and patching the Makefile to omit the download step, I get, running these commands

make RUSTCSRC
make -j4 -f minicargo.mk

Tail of output:

Run Build- DEBUG: Completed proc_macro
Run Build- DEBUG: - syntax_ext has 0 deps remaining
Run Build- DEBUG: - rustc_metadata has 2 deps remaining
Run Build- DEBUG: Building output/rustc-build/libsyntax_ext.hir - Missing
BUILDING syntax_ext from syntax_ext v0.0.0 with features []
Run Build- Calling /tmp/guix-build-mrustc-0-1.92b96b3f.drv-4/mrustc-0-1.92b96b3f/bin/mrustc rustc-1.19.0-src/src/libsyntax_ext/lib.rs --crate-name syntax_ext --crate-type rlib -g -O -o output/rustc-build/libsyntax_ext.hir -L output/rustc-build --extern fmt_macros=output/rustc-build/libfmt_macros.hir --extern log=output/rustc-build/liblog-0_3_7.hir --extern proc_macro=output/rustc-build/libproc_macro.hir --extern rustc_errors=output/rustc-build/librustc_errors.hir --extern syntax=output/rustc-build/libsyntax.hir --extern syntax_pos=output/rustc-build/libsyntax_pos.hir -L output
Run Build- DEBUG: Environment { OUT_DIR=/tmp/guix-build-mrustc-0-1.92b96b3f.drv-4/mrustc-0-1.92b96b3f/output/rustc-build/build_syntax_ext CARGO_MANIFEST_DIR=/tmp/guix-build-mrustc-0-1.92b96b3f.drv-4/mrustc-0-1.92b96b3f/rustc-1.19.0-src/src/libsyntax_ext CARGO_PKG_VERSION=0.0.0 CARGO_PKG_VERSION_MAJOR=0 CARGO_PKG_VERSION_MINOR=0 CARGO_PKG_VERSION_PATCH=0 }
Run Build- DEBUG: Completed syntax_ext
Run Build- DEBUG: - rustc_metadata has 1 deps remaining
Run Build- DEBUG: - rustc_driver has 4 deps remaining
Run Build- DEBUG: Building output/rustc-build/rustc - Missing
BUILDING rustc from rustc-main v0.0.0 with features []
Run Build- Calling /tmp/guix-build-mrustc-0-1.92b96b3f.drv-4/mrustc-0-1.92b96b3f/bin/mrustc rustc-1.19.0-src/src/rustc/rustc.rs --crate-name rustc --crate-type bin -g -O -o output/rustc-build/rustc -L output/rustc-build --extern rustc_back=output/rustc-build/librustc_back.hir --extern rustc_driver=output/rustc-build/librustc_driver.hir --extern rustdoc=output/rustc-build/librustdoc.hir -L output
Run Build- DEBUG: Environment { OUT_DIR=/tmp/guix-build-mrustc-0-1.92b96b3f.drv-4/mrustc-0-1.92b96b3f/output/rustc-build/build_rustc-main CARGO_MANIFEST_DIR=/tmp/guix-build-mrustc-0-1.92b96b3f.drv-4/mrustc-0-1.92b96b3f/rustc-1.19.0-src/src/rustc CARGO_PKG_VERSION=0.0.0 CARGO_PKG_VERSION_MAJOR=0 CARGO_PKG_VERSION_MINOR=0 CARGO_PKG_VERSION_PATCH=0 }
:0: error:0:Unable to locate crate 'rustc_driver'
Run Build- DEBUG: Compiler was terminated with signal 6
Run Build- DEBUG: See output/rustc-build/rustc_dbg.txt for the compiler output
BUILD FAILED
make: *** [minicargo.mk:69: output/rustc] Error 1

Then I tried outside outside the container just to check and without the -j, and got a similar-ish error but one that failed much more quickly:

git/mrustc$ make -f minicargo.mk
make -f Makefile all
make[1]: Entering directory '/home/ben/git/mrustc'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/home/ben/git/mrustc'
test -e bin/mrustc
make -C tools/minicargo/
make[1]: Entering directory '/home/ben/git/mrustc/tools/minicargo'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/home/ben/git/mrustc/tools/minicargo'
test -e tools/bin/minicargo
tools/bin/minicargo rustc-1.19.0-src/src/libstd --script-overrides script-overrides/stable-1.19.0-linux/ --output-dir output/ -j 1
Run Build- DEBUG: Not building output/libcore.hir - not out of date
Run Build- DEBUG: Completed core
Run Build- DEBUG: - libc has 0 deps remaining
Run Build- DEBUG: - alloc has 0 deps remaining
Run Build- DEBUG: - std_unicode has 0 deps remaining
Run Build- DEBUG: - alloc_system has 1 deps remaining
Run Build- DEBUG: - compiler_builtins has 0 deps remaining
Run Build- DEBUG: - rustc_tsan has 1 deps remaining
Run Build- DEBUG: - rustc_msan has 1 deps remaining
Run Build- DEBUG: - rustc_lsan has 1 deps remaining
Run Build- DEBUG: - rustc_asan has 1 deps remaining
Run Build- DEBUG: - unwind has 1 deps remaining
Run Build- DEBUG: - rand has 0 deps remaining
Run Build- DEBUG: - collections has 2 deps remaining
Run Build- DEBUG: - panic_abort has 1 deps remaining
Run Build- DEBUG: - std has 13 deps remaining
Run Build- DEBUG: Not building output/librand.hir - not out of date
Run Build- DEBUG: Completed rand
Run Build- DEBUG: - std has 12 deps remaining
Run Build- DEBUG: Not building output/libcompiler_builtins.hir - not out of date
Run Build- DEBUG: Completed compiler_builtins
Run Build- DEBUG: - std has 11 deps remaining
Run Build- DEBUG: Not building output/libstd_unicode.hir - not out of date
Run Build- DEBUG: Completed std_unicode
Run Build- DEBUG: - collections has 1 deps remaining
Run Build- DEBUG: - std has 10 deps remaining
Run Build- DEBUG: Not building output/liballoc.hir - not out of date
Run Build- DEBUG: Completed alloc
Run Build- DEBUG: - collections has 0 deps remaining
Run Build- DEBUG: - std has 9 deps remaining
Run Build- DEBUG: Building output/libcollections.hir - Missing
BUILDING collections from collections v0.0.0 with features []
Run Build- Calling /home/ben/git/mrustc/bin/mrustc rustc-1.19.0-src/src/libcollections/lib.rs --crate-name collections --crate-type rlib -g -O -o output/libcollections.hir -L 2 --extern alloc=output/liballoc.hir --extern core=output/libcore.hir --extern std_unicode=output/libstd_unicode.hir
Run Build- DEBUG: Environment { OUT_DIR=/home/ben/git/mrustc/output/build_collections CARGO_MANIFEST_DIR=/home/ben/git/mrustc/rustc-1.19.0-src/src/libcollections CARGO_PKG_VERSION=0.0.0 CARGO_PKG_VERSION_MAJOR=0 CARGO_PKG_VERSION_MINOR=0 CARGO_PKG_VERSION_PATCH=0 }
:0: error:0:Unable to locate crate 'core' with filename libcore.hir
Run Build- DEBUG: Compiler was terminated with signal 6
Run Build- DEBUG: See output/libcollections.hir_dbg.txt for the compiler output
BUILD FAILED
make: *** [minicargo.mk:43: output/libstd.hir] Error 1

git/mrustc$ ls output/libcore.hir
output/libcore.hir

git/mrustc$ cat output/libcollections.hir_dbg.txt
- Span: Empty span
Parse: V V V
(0.10 s) Parse: DONE
LoadCrates: V V V

Any ideas? Happy to provide further info if that would be helpful?
Thanks, ben

Resulting rustc fails when compiling cargo

I did the following:

  • Created a new Debian 9 (stretch) VM with 6GB RAM and some swap
  • Installed prerequisites
  • Did make RUSTSRC and make -f minicargo.mk
  • Added the output directory to path
  • Extracted rustc-1.19.0 to a pristine directory
  • Created config.toml with rustc=DIR
  • Attempted to run x.py and go an error

The subcommand and error are:

$ /home/vagrant/src/rustc-1.19.0-src/build/x86_64-unknown-linux-gnu/stage0/bin/cargo build --manifest-path /home/vagrant/src/rustc-1.19.0-src/src/bootstrap/Cargo.toml -vvv

*** Error in `rustc': realloc(): invalid next size: 0x00007f42f801a300 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x70bcb)[0x7f42fff44bcb]
/lib/x86_64-linux-gnu/libc.so.6(+0x76f96)[0x7f42fff4af96]
/lib/x86_64-linux-gnu/libc.so.6(+0x7a10c)[0x7f42fff4e10c]
/lib/x86_64-linux-gnu/libc.so.6(realloc+0x159)[0x7f42fff4f6e9]
rustc(+0x9b929c)[0x55f6ac95429c]
rustc(+0xafde42)[0x55f6aca98e42]
rustc(+0xafe1e1)[0x55f6aca991e1]
rustc(+0x949e1a)[0x55f6ac8e4e1a]
rustc(+0x8f3972)[0x55f6ac88e972]
rustc(+0x8f40ee)[0x55f6ac88f0ee]
rustc(+0x8f414d)[0x55f6ac88f14d]
rustc(+0x8f4499)[0x55f6ac88f499]
rustc(+0x8f44bc)[0x55f6ac88f4bc]
rustc(+0x49d80c)[0x55f6ac43880c]
rustc(+0x8c01ce)[0x55f6ac85b1ce]
rustc(+0x2fcb7c)[0x55f6ac297b7c]
rustc(+0x2fcba9)[0x55f6ac297ba9]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x7494)[0x7f4300b03494]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x3f)[0x7f42fffbcaff]
======= Memory map: ========
55f6abf9b000-55f6b02ad000 r-xp 00000000 08:01 1172331                    /home/vagrant/opt/rust-mrustc/bin/rustc
55f6b04ad000-55f6b05ed000 r--p 04312000 08:01 1172331                    /home/vagrant/opt/rust-mrustc/bin/rustc
55f6b05ed000-55f6b0699000 rw-p 04452000 08:01 1172331                    /home/vagrant/opt/rust-mrustc/bin/rustc
55f6b0699000-55f6b06c7000 rw-p 00000000 00:00 0 
55f6b162b000-55f6b165d000 rw-p 00000000 00:00 0                          [heap]
7f42f0000000-7f42f0021000 rw-p 00000000 00:00 0 
7f42f0021000-7f42f4000000 ---p 00000000 00:00 0 
7f42f8000000-7f42f803e000 rw-p 00000000 00:00 0 
7f42f803e000-7f42fc000000 ---p 00000000 00:00 0 
7f42fecbc000-7f42fecbd000 ---p 00000000 00:00 0 
7f42fecbd000-7f42ffcbd000 rw-p 00000000 00:00 0 
7f42ffcbd000-7f42ffcd3000 r-xp 00000000 08:01 259591                     /lib/x86_64-linux-gnu/libgcc_s.so.1
7f42ffcd3000-7f42ffed2000 ---p 00016000 08:01 259591                     /lib/x86_64-linux-gnu/libgcc_s.so.1
7f42ffed2000-7f42ffed3000 r--p 00015000 08:01 259591                     /lib/x86_64-linux-gnu/libgcc_s.so.1
7f42ffed3000-7f42ffed4000 rw-p 00016000 08:01 259591                     /lib/x86_64-linux-gnu/libgcc_s.so.1
7f42ffed4000-7f4300069000 r-xp 00000000 08:01 259595                     /lib/x86_64-linux-gnu/libc-2.24.so
7f4300069000-7f4300269000 ---p 00195000 08:01 259595                     /lib/x86_64-linux-gnu/libc-2.24.so
7f4300269000-7f430026d000 r--p 00195000 08:01 259595                     /lib/x86_64-linux-gnu/libc-2.24.so
7f430026d000-7f430026f000 rw-p 00199000 08:01 259595                     /lib/x86_64-linux-gnu/libc-2.24.so
7f430026f000-7f4300273000 rw-p 00000000 00:00 0 
7f4300273000-7f4300275000 r-xp 00000000 08:01 259614                     /lib/x86_64-linux-gnu/libutil-2.24.so
7f4300275000-7f4300474000 ---p 00002000 08:01 259614                     /lib/x86_64-linux-gnu/libutil-2.24.so
7f4300474000-7f4300475000 r--p 00001000 08:01 259614                     /lib/x86_64-linux-gnu/libutil-2.24.so
7f4300475000-7f4300476000 rw-p 00002000 08:01 259614                     /lib/x86_64-linux-gnu/libutil-2.24.so
7f4300476000-7f43005e8000 r-xp 00000000 08:01 135059                     /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.22
7f43005e8000-7f43007e8000 ---p 00172000 08:01 135059                     /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.22
7f43007e8000-7f43007f2000 r--p 00172000 08:01 135059                     /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.22
7f43007f2000-7f43007f4000 rw-p 0017c000 08:01 135059                     /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.22
7f43007f4000-7f43007f8000 rw-p 00000000 00:00 0 
7f43007f8000-7f43008fb000 r-xp 00000000 08:01 259599                     /lib/x86_64-linux-gnu/libm-2.24.so
7f43008fb000-7f4300afa000 ---p 00103000 08:01 259599                     /lib/x86_64-linux-gnu/libm-2.24.so
7f4300afa000-7f4300afb000 r--p 00102000 08:01 259599                     /lib/x86_64-linux-gnu/libm-2.24.so
7f4300afb000-7f4300afc000 rw-p 00103000 08:01 259599                     /lib/x86_64-linux-gnu/libm-2.24.so
7f4300afc000-7f4300b14000 r-xp 00000000 08:01 259610                     /lib/x86_64-linux-gnu/libpthread-2.24.so
7f4300b14000-7f4300d13000 ---p 00018000 08:01 259610                     /lib/x86_64-linux-gnu/libpthread-2.24.so
7f4300d13000-7f4300d14000 r--p 00017000 08:01 259610                     /lib/x86_64-linux-gnu/libpthread-2.24.so
7f4300d14000-7f4300d15000 rw-p 00018000 08:01 259610                     /lib/x86_64-linux-gnu/libpthread-2.24.so
7f4300d15000-7f4300d19000 rw-p 00000000 00:00 0 
7f4300d19000-7f4300d20000 r-xp 00000000 08:01 259612                     /lib/x86_64-linux-gnu/librt-2.24.so
7f4300d20000-7f4300f1f000 ---p 00007000 08:01 259612                     /lib/x86_64-linux-gnu/librt-2.24.so
7f4300f1f000-7f4300f20000 r--p 00006000 08:01 259612                     /lib/x86_64-linux-gnu/librt-2.24.so
7f4300f20000-7f4300f21000 rw-p 00007000 08:01 259612                     /lib/x86_64-linux-gnu/librt-2.24.so
7f4300f21000-7f4300f24000 r-xp 00000000 08:01 259598                     /lib/x86_64-linux-gnu/libdl-2.24.so
7f4300f24000-7f4301123000 ---p 00003000 08:01 259598                     /lib/x86_64-linux-gnu/libdl-2.24.so
7f4301123000-7f4301124000 r--p 00002000 08:01 259598                     /lib/x86_64-linux-gnu/libdl-2.24.so
7f4301124000-7f4301125000 rw-p 00003000 08:01 259598                     /lib/x86_64-linux-gnu/libdl-2.24.so
7f4301125000-7f4301148000 r-xp 00000000 08:01 259590                     /lib/x86_64-linux-gnu/ld-2.24.so
7f4301334000-7f430133a000 rw-p 00000000 00:00 0 
7f4301340000-7f4301348000 rw-p 00000000 00:00 0 
7f4301348000-7f4301349000 r--p 00023000 08:01 259590                     /lib/x86_64-linux-gnu/ld-2.24.so
7f4301349000-7f430134a000 rw-p 00024000 08:01 259590                     /lib/x86_64-linux-gnu/ld-2.24.so
7f430134a000-7f430134b000 rw-p 00000000 00:00 0 
7ffcdb83c000-7ffcdb83d000 ---p 00000000 00:00 0 
7ffcdc01b000-7ffcdc03c000 rw-p 00000000 00:00 0                          [stack]
7ffcdc1de000-7ffcdc1e0000 r--p 00000000 00:00 0                          [vvar]
7ffcdc1e0000-7ffcdc1e2000 r-xp 00000000 00:00 0                          [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  [vsyscall]
*** Error in `rustc': realloc(): invalid next size: 0x00007fb48401a9e0 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x70bcb)[0x7fb48ba6cbcb]
/lib/x86_64-linux-gnu/libc.so.6(+0x76f96)[0x7fb48ba72f96]
/lib/x86_64-linux-gnu/libc.so.6(+0x7a10c)[0x7fb48ba7610c]
/lib/x86_64-linux-gnu/libc.so.6(realloc+0x159)[0x7fb48ba776e9]
rustc(+0x9b929c)[0x56483872c29c]
rustc(+0xafde42)[0x564838870e42]
rustc(+0xafe1e1)[0x5648388711e1]
rustc(+0x949e1a)[0x5648386bce1a]
rustc(+0x8f3972)[0x564838666972]
rustc(+0x8f40ee)[0x5648386670ee]
rustc(+0x8f414d)[0x56483866714d]
rustc(+0x8f4499)[0x564838667499]
rustc(+0x8f44bc)[0x5648386674bc]
rustc(+0x49d80c)[0x56483821080c]
rustc(+0x8c01ce)[0x5648386331ce]
rustc(+0x2fcb7c)[0x56483806fb7c]
rustc(+0x2fcba9)[0x56483806fba9]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x7494)[0x7fb48c62b494]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x3f)[0x7fb48bae4aff]
======= Memory map: ========
564837d73000-56483c085000 r-xp 00000000 08:01 1172331                    /home/vagrant/opt/rust-mrustc/bin/rustc
56483c285000-56483c3c5000 r--p 04312000 08:01 1172331                    /home/vagrant/opt/rust-mrustc/bin/rustc
56483c3c5000-56483c471000 rw-p 04452000 08:01 1172331                    /home/vagrant/opt/rust-mrustc/bin/rustc
56483c471000-56483c49f000 rw-p 00000000 00:00 0 
56483da32000-56483da64000 rw-p 00000000 00:00 0                          [heap]
7fb47c000000-7fb47c021000 rw-p 00000000 00:00 0 
7fb47c021000-7fb480000000 ---p 00000000 00:00 0 
7fb484000000-7fb48403e000 rw-p 00000000 00:00 0 
7fb48403e000-7fb488000000 ---p 00000000 00:00 0 
7fb48a7e4000-7fb48a7e5000 ---p 00000000 00:00 0 
7fb48a7e5000-7fb48b7e5000 rw-p 00000000 00:00 0 
7fb48b7e5000-7fb48b7fb000 r-xp 00000000 08:01 259591                     /lib/x86_64-linux-gnu/libgcc_s.so.1
7fb48b7fb000-7fb48b9fa000 ---p 00016000 08:01 259591                     /lib/x86_64-linux-gnu/libgcc_s.so.1
7fb48b9fa000-7fb48b9fb000 r--p 00015000 08:01 259591                     /lib/x86_64-linux-gnu/libgcc_s.so.1
7fb48b9fb000-7fb48b9fc000 rw-p 00016000 08:01 259591                     /lib/x86_64-linux-gnu/libgcc_s.so.1
7fb48b9fc000-7fb48bb91000 r-xp 00000000 08:01 259595                     /lib/x86_64-linux-gnu/libc-2.24.so
7fb48bb91000-7fb48bd91000 ---p 00195000 08:01 259595                     /lib/x86_64-linux-gnu/libc-2.24.so
7fb48bd91000-7fb48bd95000 r--p 00195000 08:01 259595                     /lib/x86_64-linux-gnu/libc-2.24.so
7fb48bd95000-7fb48bd97000 rw-p 00199000 08:01 259595                     /lib/x86_64-linux-gnu/libc-2.24.so
7fb48bd97000-7fb48bd9b000 rw-p 00000000 00:00 0 
7fb48bd9b000-7fb48bd9d000 r-xp 00000000 08:01 259614                     /lib/x86_64-linux-gnu/libutil-2.24.so
7fb48bd9d000-7fb48bf9c000 ---p 00002000 08:01 259614                     /lib/x86_64-linux-gnu/libutil-2.24.so
7fb48bf9c000-7fb48bf9d000 r--p 00001000 08:01 259614                     /lib/x86_64-linux-gnu/libutil-2.24.so
7fb48bf9d000-7fb48bf9e000 rw-p 00002000 08:01 259614                     /lib/x86_64-linux-gnu/libutil-2.24.so
7fb48bf9e000-7fb48c110000 r-xp 00000000 08:01 135059                     /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.22
7fb48c110000-7fb48c310000 ---p 00172000 08:01 135059                     /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.22
7fb48c310000-7fb48c31a000 r--p 00172000 08:01 135059                     /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.22
7fb48c31a000-7fb48c31c000 rw-p 0017c000 08:01 135059                     /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.22
7fb48c31c000-7fb48c320000 rw-p 00000000 00:00 0 
7fb48c320000-7fb48c423000 r-xp 00000000 08:01 259599                     /lib/x86_64-linux-gnu/libm-2.24.so
7fb48c423000-7fb48c622000 ---p 00103000 08:01 259599                     /lib/x86_64-linux-gnu/libm-2.24.so
7fb48c622000-7fb48c623000 r--p 00102000 08:01 259599                     /lib/x86_64-linux-gnu/libm-2.24.so
7fb48c623000-7fb48c624000 rw-p 00103000 08:01 259599                     /lib/x86_64-linux-gnu/libm-2.24.so
7fb48c624000-7fb48c63c000 r-xp 00000000 08:01 259610                     /lib/x86_64-linux-gnu/libpthread-2.24.so
7fb48c63c000-7fb48c83b000 ---p 00018000 08:01 259610                     /lib/x86_64-linux-gnu/libpthread-2.24.so
7fb48c83b000-7fb48c83c000 r--p 00017000 08:01 259610                     /lib/x86_64-linux-gnu/libpthread-2.24.so
7fb48c83c000-7fb48c83d000 rw-p 00018000 08:01 259610                     /lib/x86_64-linux-gnu/libpthread-2.24.so
7fb48c83d000-7fb48c841000 rw-p 00000000 00:00 0 
7fb48c841000-7fb48c848000 r-xp 00000000 08:01 259612                     /lib/x86_64-linux-gnu/librt-2.24.so
7fb48c848000-7fb48ca47000 ---p 00007000 08:01 259612                     /lib/x86_64-linux-gnu/librt-2.24.so
7fb48ca47000-7fb48ca48000 r--p 00006000 08:01 259612                     /lib/x86_64-linux-gnu/librt-2.24.so
7fb48ca48000-7fb48ca49000 rw-p 00007000 08:01 259612                     /lib/x86_64-linux-gnu/librt-2.24.so
7fb48ca49000-7fb48ca4c000 r-xp 00000000 08:01 259598                     /lib/x86_64-linux-gnu/libdl-2.24.so
7fb48ca4c000-7fb48cc4b000 ---p 00003000 08:01 259598                     /lib/x86_64-linux-gnu/libdl-2.24.so
7fb48cc4b000-7fb48cc4c000 r--p 00002000 08:01 259598                     /lib/x86_64-linux-gnu/libdl-2.24.so
7fb48cc4c000-7fb48cc4d000 rw-p 00003000 08:01 259598                     /lib/x86_64-linux-gnu/libdl-2.24.so
7fb48cc4d000-7fb48cc70000 r-xp 00000000 08:01 259590                     /lib/x86_64-linux-gnu/ld-2.24.so
7fb48ce5c000-7fb48ce62000 rw-p 00000000 00:00 0 
7fb48ce68000-7fb48ce70000 rw-p 00000000 00:00 0 
7fb48ce70000-7fb48ce71000 r--p 00023000 08:01 259590                     /lib/x86_64-linux-gnu/ld-2.24.so
7fb48ce71000-7fb48ce72000 rw-p 00024000 08:01 259590                     /lib/x86_64-linux-gnu/ld-2.24.so
7fb48ce72000-7fb48ce73000 rw-p 00000000 00:00 0 
7ffdc73f0000-7ffdc73f1000 ---p 00000000 00:00 0 
7ffdc7bcf000-7ffdc7bf0000 rw-p 00000000 00:00 0                          [stack]
7ffdc7bf6000-7ffdc7bf8000 r--p 00000000 00:00 0                          [vvar]
7ffdc7bf8000-7ffdc7bfa000 r-xp 00000000 00:00 0                          [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  [vsyscall]
error: failed to run `rustc` to learn about target-specific information

Caused by:
  process didn't exit successfully: `rustc - --crate-name ___ --print=file-names --crate-type bin --crate-type rlib --target x86_64-unknown-linux-gnu` (signal: 6, SIGABRT: process abort signal)

No member named `_0`

CC=gcc CXX=g++ make -f minicargo.mk is failing with many errors like the following:

output/libcore.hir.o.c:156961:15: error: ‘struct s__ZN4core3str14ParseBoolError’ has no member named ‘_0’
  var0 = & arg0->_0; // Local(0) = Borrow(0, Shared, Field(0, Deref(Argument(0))))
               ^
output/libcore.hir.o.c:156962:4: error: ‘struct s__ZN4core3str14ParseBoolError’ has no member named ‘_0’
  rv._0 = (*var0); // Return = Struct(::"core"::str::ParseBoolError, {Deref(Local(0))})
    ^

Same error in Travis. It looks like this was introduced in c7e7652.

::std::strchr return type differs from ::std::string position arg

in src/main.cpp, line 728:

auto* pos = ::std::strchr(desc, '=');

a few lines later:

auto name = ::std::string(desc, pos);

compiler throws an error:

src/main.cpp:728:52: error: Invalid conversion from 'char*' to 'std::basic_string<char>::size_type {aka long unsigned int}'

Changing pos to *pos makes it compile here, but not sure if that is the correct solution.

Borrow checking with polonius?

Hi! Perhaps borrow checking could be implemented in future with use of polonius, a library that models the borrow checker, if this is in scope/relevant. I thought that a reason that borrow checking isn't implemented in mrustc is the amount of work required to do it, but perhaps this library could assist with that?

Error while building rustc 1.19.0 using mrustc 0.8.0 - CFG_PREFIX

> /gnu/store/8c72bkxlqa8pjy8ff7wvfwrbyardb0yl-mrustc-0.8.0/bin/mrustc src/librustc_trans/lib.rs --crate-name rustc_trans --crate-type rlib -g --cfg debug_assertions -O -o output/rustc-build/librustc_trans.hir -L output/rustc-build --extern flate=output/rustc-build/libflate.hir --extern log=output/rustc-build/liblog-0_3_7.hir --extern owning_ref=output/rustc-build/libowning_ref-0_3_3.hir --extern rustc=output/rustc-build/librustc.hir --extern rustc_back=output/rustc-build/librustc_back.hir --extern rustc_bitflags=output/rustc-build/librustc_bitflags.hir --extern rustc_const_math=output/rustc-build/librustc_const_math.hir --extern rustc_data_structures=output/rustc-build/librustc_data_structures.hir --extern rustc_errors=output/rustc-build/librustc_errors.hir --extern rustc_incremental=output/rustc-build/librustc_incremental.hir --extern rustc_llvm=output/rustc-build/librustc_llvm.hir --extern rustc_platform_intrinsics=output/rustc-build/librustc_platform_intrinsics.hir --extern serialize=output/rustc-build/libserialize.hir --extern syntax=output/rustc-build/libsyntax.hir --extern syntax_pos=output/rustc-build/libsyntax_pos.hir -L /gnu/store/8c72bkxlqa8pjy8ff7wvfwrbyardb0yl-mrustc-0.8.0/lib/mrust
mrustc: src/hir_typeck/expr_cs.cpp:4027: void Context::equate_types_shadow(const Span&, const HIR::TypeRef&, bool): Assertion `!"ERROR: destructed tagged union used"' failed.
BUILD FAILED

(Using mrustc compiled with llvm 3.9.1 and gcc 5.5.0)

Note: This is part of a larger effort to bootstrap Mozilla's rust implementation using mrustc. Are we setting this up correctly? (should we use mrustc 0.8.0 to build rustc 1.19.0 or rather rustc 1.20.0?)

Host system: GuixSD 0.15.0.
gcc: 5.5.0

Generate headers

My current work on esp-rs requires using the generated C code as a library from a C++ shim. Any chance of mrustc generating headers? makeheaders was unable to do it adequately.

Patching

Can't patch rustcsrc when execute "make RUSTCSRC".

Parse macro invocation as $:item

The following compiles with rustc 1.19.0 but not mrustc. This is minimized from the libc crate.

macro_rules! outer {
    ($it:item) => {}
}

outer! {
    inner! {}
}
lib.rs:5: BUG:src/macro_rules/eval.cpp:1925: TODO: Macro_InvokeRules_MatchPattern - No arm matched

Suggestion to make rustc-nightly fetch in Makefile optional (and more)

About RUSTSRC in Makefile (https://github.com/thepowersgang/mrustc/blob/master/Makefile#L168):

This will not work in most sane build environments. Most operating systems will have to fetch rustc-nightly in advance due to isolated build-environments. I suggest to remove the rule and check for a local file, or anything similar (better yet, but I'm not a rust dev: try to implement tests without dependency on rustc-nightly). For example for GNU Guix I will fetch the rustc-nightly tarball as a separate file before the build starts.

I'm really looking forward where this project is going, with the bootstrapping issue of rustc (rustc requiring rustc for build).
As far as I understand mrustc, just taking a first short look at the code, it only requires the rustc-nightly source for tests, correct?

Error compiling.

I tried build mrustc on cygwin. There was an error:
src/main.cpp:744:52: error: no matching function for call to 'std::basic_string::basic_string(const char*&, char*&)'
auto name = ::std::string(desc, pos);
..............................
src/main.cpp:744:52: error: invalid conversion from 'char*' to 'char' [-fpermissive]
auto name = ::std::string(desc, pos);

I was able to fix it by changing src / main.cpp: 744: "pos" -> "* pos".

Wildcard `use *`

The following compiles with rustc since 1.14.0 but not mrustc:

mod m {
    use *;
}

fn main() {}
Parse: V V V
star.rs:2: Unexpected(TOK_STAR)
terminate called after throwing an instance of 'ParseError::Unexpected'
  what():  std::exception

We use this in Syn within some generated code, so it becomes necessary for building serde_derive.
syn/codegen/src/main.rs#L1015.

mrustc segfaults at src/main.cpp:145 / debug_output

I'm building with gcc 7.2.0 on Slackware64-current.

mrustc segfaults immediately after building at src/main.cpp:145

Steps taken:

$ make -j4 -f minicargo.mk bin/mrustc tools/bin/minicargo
$ valgrind bin/mrustc
[....]
==16124== Process terminating with default action of signal 11 (SIGSEGV)
==16124==  Access not within mapped region at address 0xFFFFFFFFFFFFFFE8
==16124==    at 0x40E85C: operator<< <char, std::char_traits<char>, std::allocator<char> > (basic_string.h:6087)
==16124==    by 0x40E85C: debug_output(int, char const*) (main.cpp:145)
==16124==    by 0x41D8B7: Span::Span() (span.cpp:38)
==16124==    by 0x40E16B: __static_initialization_and_destruction_0 (codegen_c.cpp:4854)
==16124==    by 0x40E16B: _GLOBAL__sub_I__Z27Trans_Codegen_GetGeneratorCRKN3HIR5CrateERKSs (codegen_c.cpp:4860)
==16124==    by 0x8C2F75: ??? (in /home/aclemons/mrustc/mrustc-dc10bdbc8ad52e3a4f2a2b3bf2f2fa9b7c6194ee/bin/mrustc)
==16124==    by 0x404913: ??? (in /home/aclemons/mrustc/mrustc-dc10bdbc8ad52e3a4f2a2b3bf2f2fa9b7c6194ee/bin/mrustc)
==16124==    by 0x40003F: ??? (in /home/aclemons/mrustc/mrustc-dc10bdbc8ad52e3a4f2a2b3bf2f2fa9b7c6194ee/bin/mrustc)
==16124==    by 0x8C2F00: __libc_csu_init (in /home/aclemons/mrustc/mrustc-dc10bdbc8ad52e3a4f2a2b3bf2f2fa9b7c6194ee/bin/mrustc)
==16124==    by 0x595AFBA: (below main) (in /lib64/libc-2.26.so)
==16124==  If you believe this happened as a result of a stack
==16124==  overflow in your program's main thread (unlikely but
==16124==  possible), you can try to increase the size of the
==16124==  main thread stack using the --main-stacksize= flag.
==16124==  The main thread stack size used in this run was 8388608.
[....]

FYI, I get the same behaviour on Slackware64-14.2 with gcc 5.3.0.

I'm current building dc10bdb.

Unexpanded macro in return type

This is minimized from Syn 0.12 which uses the Token! type macro heavily internally.

macro_rules! Ty {
    () => { u8 }
}

fn f() -> Option<Ty![]> {
    None
}
BUG:src/resolve/absolute.cpp:1525: Resolve_Absolute_Type - Encountered an unexpanded macro in type - Ty! /*null*/

rust-1.23 fails at minicargo

I (naively) tried to build rust 1.23.0 with mrustc.

It fails while running minicargo. I straced it, here's the output:

# strace tools/bin/minicargo rustc-1.23.0-src/src/libstd --script-overrides script-overrides/stable-1.23.0-linux/ --output-dir output/ -j 1

execve("tools/bin/minicargo", ["tools/bin/minicargo", "rustc-1.23.0-src/src/libstd", "--script-overrides", "script-overrides/stable-1.23.0-l"..., "--output-dir", "output/", "-j", "1"], 0x7ffe5ecfbca8 /* 61 vars */) = 0
brk(NULL)                               = 0x5610c8455000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=145334, ...}) = 0
mmap(NULL, 145334, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f8911ed8000
close(3)                                = 0
openat(AT_FDCWD, "/usr/lib/libpthread.so.0", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\0b\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=2348680, ...}) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f8911ed6000
mmap(NULL, 2221128, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f8911ab9000
mprotect(0x7f8911ad3000, 2093056, PROT_NONE) = 0
mmap(0x7f8911cd2000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x19000) = 0x7f8911cd2000
mmap(0x7f8911cd4000, 13384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f8911cd4000
close(3)                                = 0
openat(AT_FDCWD, "/usr/lib/libstdc++.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\20+\t\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=2089240, ...}) = 0
mmap(NULL, 4197440, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f89116b8000
mprotect(0x7f89118a6000, 2093056, PROT_NONE) = 0
mmap(0x7f8911aa5000, 69632, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1ed000) = 0x7f8911aa5000
mmap(0x7f8911ab6000, 11328, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f8911ab6000
close(3)                                = 0
openat(AT_FDCWD, "/usr/lib/libm.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0000x\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=5205464, ...}) = 0
mmap(NULL, 3457800, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f891136b000
mprotect(0x7f89114b7000, 2093056, PROT_NONE) = 0
mmap(0x7f89116b6000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x14b000) = 0x7f89116b6000
close(3)                                = 0
openat(AT_FDCWD, "/usr/lib/libgcc_s.so.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\300*\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=92576, ...}) = 0
mmap(NULL, 2188336, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f8911154000
mprotect(0x7f891116a000, 2093056, PROT_NONE) = 0
mmap(0x7f8911369000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x15000) = 0x7f8911369000
close(3)                                = 0
openat(AT_FDCWD, "/usr/lib/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0@\21\2\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=16471224, ...}) = 0
mmap(NULL, 3885664, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f8910d9f000
mprotect(0x7f8910f4a000, 2097152, PROT_NONE) = 0
mmap(0x7f891114a000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1ab000) = 0x7f891114a000
mmap(0x7f8911150000, 14944, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f8911150000
close(3)                                = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f8911ed4000
mmap(NULL, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f8911ed1000
arch_prctl(ARCH_SET_FS, 0x7f8911ed1740) = 0
mprotect(0x7f891114a000, 16384, PROT_READ) = 0
mprotect(0x7f8911369000, 4096, PROT_READ) = 0
mprotect(0x7f89116b6000, 4096, PROT_READ) = 0
mprotect(0x7f8911aa5000, 53248, PROT_READ) = 0
mprotect(0x7f8911cd2000, 4096, PROT_READ) = 0
mprotect(0x5610c6c4b000, 4096, PROT_READ) = 0
mprotect(0x7f8911efc000, 4096, PROT_READ) = 0
munmap(0x7f8911ed8000, 145334)          = 0
set_tid_address(0x7f8911ed1a10)         = 25856
set_robust_list(0x7f8911ed1a20, 24)     = 0
rt_sigaction(SIGRTMIN, {sa_handler=0x7f8911abec70, sa_mask=[], sa_flags=SA_RESTORER|SA_SIGINFO, sa_restorer=0x7f8911acb7d0}, NULL, 8) = 0
rt_sigaction(SIGRT_1, {sa_handler=0x7f8911abed00, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART|SA_SIGINFO, sa_restorer=0x7f8911acb7d0}, NULL, 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [RTMIN RT_1], NULL, 8) = 0
prlimit64(0, RLIMIT_STACK, NULL, {rlim_cur=8192*1024, rlim_max=RLIM64_INFINITY}) = 0
brk(NULL)                               = 0x5610c8455000
brk(0x5610c8476000)                     = 0x5610c8476000
futex(0x7f8911ab6c9c, FUTEX_WAKE_PRIVATE, 2147483647) = 0
futex(0x7f8911ab6ca8, FUTEX_WAKE_PRIVATE, 2147483647) = 0
openat(AT_FDCWD, "rustc-1.23.0-src/src/libstd/Cargo.toml", O_RDONLY) = 3
read(3, "[package]\nauthors = [\"The Rust P"..., 8191) = 1489
read(3, "", 8191)                       = 0
openat(AT_FDCWD, "rustc-1.23.0-src/src/libstd/build.rs", O_RDONLY) = 4
close(4)                                = 0
close(3)                                = 0
openat(AT_FDCWD, "rustc-1.23.0-src/src/libstd/../liballoc/Cargo.toml", O_RDONLY) = 3
close(3)                                = 0
openat(AT_FDCWD, "rustc-1.23.0-src/src/liballoc/Cargo.toml", O_RDONLY) = 3
read(3, "[package]\nauthors = [\"The Rust P"..., 8191) = 393
read(3, "", 8191)                       = 0
close(3)                                = 0
openat(AT_FDCWD, "rustc-1.23.0-src/src/liballoc/../libcore/Cargo.toml", O_RDONLY) = 3
close(3)                                = 0
openat(AT_FDCWD, "rustc-1.23.0-src/src/libcore/Cargo.toml", O_RDONLY) = 3
read(3, "[package]\nauthors = [\"The Rust P"..., 8191) = 277
read(3, "", 8191)                       = 0
close(3)                                = 0
openat(AT_FDCWD, "rustc-1.23.0-src/src/liballoc/../libstd_unicode/Cargo.toml", O_RDONLY) = 3
close(3)                                = 0
openat(AT_FDCWD, "rustc-1.23.0-src/src/libstd_unicode/Cargo.toml", O_RDONLY) = 3
read(3, "[package]\nauthors = [\"The Rust P"..., 8191) = 268
read(3, "", 8191)                       = 0
close(3)                                = 0
openat(AT_FDCWD, "rustc-1.23.0-src/src/libstd_unicode/../libcore/Cargo.toml", O_RDONLY) = 3
close(3)                                = 0
openat(AT_FDCWD, "rustc-1.23.0-src/src/libstd/../liballoc_system/Cargo.toml", O_RDONLY) = 3
close(3)                                = 0
openat(AT_FDCWD, "rustc-1.23.0-src/src/liballoc_system/Cargo.toml", O_RDONLY) = 3
read(3, "[package]\nauthors = [\"The Rust P"..., 8191) = 474
rt_sigprocmask(SIG_UNBLOCK, [ABRT], NULL, 8) = 0
rt_sigprocmask(SIG_BLOCK, ~[RTMIN RT_1], [], 8) = 0
getpid()                                = 25856
gettid()                                = 25856
tgkill(25856, 25856, SIGABRT)           = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
--- SIGABRT {si_signo=SIGABRT, si_code=SI_TKILL, si_pid=25856, si_uid=1000} ---
+++ killed by SIGABRT +++
[1]    25854 abort      strace tools/bin/minicargo rustc-1.23.0-src/src/libstd --script-overrides    

script-overrides/stable-1.23.0-linux is a symlink to script-overrides/stable-1.19.0-linux

I guess it's due some parsing issues of the Cargo.toml.

Fails to build under x86 (32bit): Excessive memory usage

Opening this so we have a place to track remaining issues for x86 support.

Building 42bdc18 with GCC 5.5 fails as below:

[...]
BUILDING core from core v0.0.0 with features []
output/libcore.hir.o.c: In function ‘_ZRI$aLusize$aR9max_value’:
output/libcore.hir.o.c:54780:7: warning: large integer implicitly truncated to unsigned type [-Woverflow]
  rv = 0xffffffffffffffffull; // Return = Constant(18446744073709551615 usize)
       ^
output/libcore.hir.o.c: In function ‘_ZRI$aLusize$aR14saturating_add’:
output/libcore.hir.o.c:55084:9: warning: large integer implicitly truncated to unsigned type [-Woverflow]
  var1 = 0xffffffffffffffffull; // Local(1) = Constant(18446744073709551615 usize)
         ^
output/libcore.hir.o.c: In function ‘_ZRI$aLusize$aR14saturating_mul’:
output/libcore.hir.o.c:55105:68: warning: large integer implicitly truncated to unsigned type [-Woverflow]
  rv = _ZRI$aL_ZN4core6option6Option$aLusize$aR$aR9unwrap_or( var0, 0xffffffffffffffffull );
                                                                    ^
output/libcore.hir.o.c: In function ‘_ZRI$aL_ZN4core4cell12BorrowRefMut$aR3new’:
output/libcore.hir.o.c:67942:60: warning: large integer implicitly truncated to unsigned type [-Woverflow]
  var2 = _ZRI$aL_ZN4core4cell4Cell$aLusize$aR$aR3set( arg0, 0xffffffffffffffffull );
                                                            ^
output/libcore.hir.o.c: In function ‘_ZRI$aL_ZN4core3str7pattern14TwoWaySearcher$aR3new’:
output/libcore.hir.o.c:79087:13: warning: large integer implicitly truncated to unsigned type [-Woverflow]
  var14._6 = 0xffffffffffffffffull;
             ^
output/libcore.hir.o.c:79088:13: warning: large integer implicitly truncated to unsigned type [-Woverflow]
  var14._7 = 0xffffffffffffffffull; // Local(14) = Struct(::"core"::str::pattern::TwoWaySearcher, {Local(18), Local(21), Local(22), Lo
             ^
output/libcore.hir.o.c: In function ‘_ZRK$aLusize_as__ZN4core7convert7TryFrom$aLusize$aR$aR8try_from’:
output/libcore.hir.o.c:84805:9: warning: large integer implicitly truncated to unsigned type [-Woverflow]
  var2 = 0xffffffffffffffffull; // Local(2) = Constant(18446744073709551615 usize)
         ^
output/libcore.hir.o.c: In function ‘_ZRK$aLusize_as__ZN4core7convert7TryFrom$aLisize$aR$aR8try_from’:
output/libcore.hir.o.c:84849:9: warning: large integer implicitly truncated to unsigned type [-Woverflow]
  var1 = 0xffffffffffffffffull; // Local(1) = Constant(18446744073709551615 usize)
         ^
output/libcore.hir.o.c: In function ‘_ZRK$aLusize_as__ZN4core7convert7TryFrom$aLu8$aR$aR8try_from’:
output/libcore.hir.o.c:84896:9: warning: large integer implicitly truncated to unsigned type [-Woverflow]
  var2 = 0xffffffffffffffffull; // Local(2) = Constant(18446744073709551615 usize)
         ^
output/libcore.hir.o.c: In function ‘_ZRK$aLusize_as__ZN4core7convert7TryFrom$aLi8$aR$aR8try_from’:
output/libcore.hir.o.c:84941:9: warning: large integer implicitly truncated to unsigned type [-Woverflow]
  var1 = 0xffffffffffffffffull; // Local(1) = Constant(18446744073709551615 usize)
         ^
output/libcore.hir.o.c: In function ‘_ZRK$aLusize_as__ZN4core7convert7TryFrom$aLu16$aR$aR8try_from’:
output/libcore.hir.o.c:84988:9: warning: large integer implicitly truncated to unsigned type [-Woverflow]
  var2 = 0xffffffffffffffffull; // Local(2) = Constant(18446744073709551615 usize)
         ^
output/libcore.hir.o.c: In function ‘_ZRK$aLusize_as__ZN4core7convert7TryFrom$aLi16$aR$aR8try_from’:
output/libcore.hir.o.c:85033:9: warning: large integer implicitly truncated to unsigned type [-Woverflow]
  var1 = 0xffffffffffffffffull; // Local(1) = Constant(18446744073709551615 usize)
         ^
output/libcore.hir.o.c: In function ‘_ZRK$aLusize_as__ZN4core7convert7TryFrom$aLu32$aR$aR8try_from’:
output/libcore.hir.o.c:85080:9: warning: large integer implicitly truncated to unsigned type [-Woverflow]
  var2 = 0xffffffffffffffffull; // Local(2) = Constant(18446744073709551615 usize)
         ^
output/libcore.hir.o.c: In function ‘_ZRK$aLusize_as__ZN4core7convert7TryFrom$aLi32$aR$aR8try_from’:
output/libcore.hir.o.c:85125:9: warning: large integer implicitly truncated to unsigned type [-Woverflow]
  var1 = 0xffffffffffffffffull; // Local(1) = Constant(18446744073709551615 usize)
         ^
output/libcore.hir.o.c: In function ‘_ZRK$aLusize_as__ZN4core7convert7TryFrom$aLu64$aR$aR8try_from’:
output/libcore.hir.o.c:85172:9: warning: large integer implicitly truncated to unsigned type [-Woverflow]
  var2 = 0xffffffffffffffffull; // Local(2) = Constant(18446744073709551615 usize)
         ^
output/libcore.hir.o.c: In function ‘_ZRK$aLusize_as__ZN4core7convert7TryFrom$aLi64$aR$aR8try_from’:
output/libcore.hir.o.c:85217:9: warning: large integer implicitly truncated to unsigned type [-Woverflow]
  var1 = 0xffffffffffffffffull; // Local(1) = Constant(18446744073709551615 usize)
         ^
output/libcore.hir.o.c: In function ‘_ZRK$aLusize_as__ZN4core7convert7TryFrom$aLu128$aR$aR8try_from’:
output/libcore.hir.o.c:85263:9: warning: large integer implicitly truncated to unsigned type [-Woverflow]
  var2 = 0xffffffffffffffffull; // Local(2) = Constant(18446744073709551615 usize)
         ^
output/libcore.hir.o.c: In function ‘_ZRK$aLusize_as__ZN4core7convert7TryFrom$aLi128$aR$aR8try_from’:
output/libcore.hir.o.c:85306:9: warning: large integer implicitly truncated to unsigned type [-Woverflow]
  var1 = 0xffffffffffffffffull; // Local(1) = Constant(18446744073709551615 usize)
         ^
output/libcore.hir.o.c: In function ‘_ZRK$aLusize_as__ZN4core3num18FromStrRadixHelper$aR9max_value’:
output/libcore.hir.o.c:85938:7: warning: large integer implicitly truncated to unsigned type [-Woverflow]
  rv = 0xffffffffffffffffull; // Return = Constant(18446744073709551615 usize)
       ^
BUILDING rand from rand v0.0.0 with features []
BUILDING compiler_builtins from compiler_builtins v0.0.0 with features []
Macro:why_are_abi_strings_checked_by_parser:0: BUG:src/hir/from_ast.cpp:901: TODO: LowerHIR_Struct - Handle struct repr 'simd'
rustc-1.19.0-src/src/libcompiler_builtins/lib.rs:719: note: From here
BUILD FAILED
minicargo.mk:63: recipe for target 'output/libstd.hir' failed
make: *** [output/libstd.hir] Error 1

Fails to build libgcc-0_3_50.hir on aarch64 musl

I’m getting weird error when building on aarch64 musl system:

Run Build- DEBUG: Building output/rustc-build/libgcc-0_3_50.hir - Missing
BUILDING gcc from gcc v0.3.50 with features []
Run Build- Calling /home/jirutjak/aports/testing/rust-bootstrap/src/mrustc-1a16def28935548e29be0fe5a632e25c83045924/bin/mrustc rustc-1.19.0-src/src/vendor/gcc/src/lib.rs --crate-name gcc --crate-type rlib --crate-tag 0_3_50 -g --cfg debug_assertions -O -o output/rustc-build/libgcc-0_3_50.hir -L output/rustc-build -L output
Run Build- DEBUG: Environment { OUT_DIR=/home/jirutjak/aports/testing/rust-bootstrap/src/mrustc-1a16def28935548e29be0fe5a632e25c83045924/output/rustc-build/build_gcc CARGO_MANIFEST_DIR=/home/jirutjak/aports/testing/rust-bootstrap/src/mrustc-1a16def28935548e29be0fe5a632e25c83045924/rustc-1.19.0-src/src/vendor/gcc CARGO_PKG_VERSION=0.3.50 CARGO_PKG_VERSION_MAJOR=0 CARGO_PKG_VERSION_MINOR=3 CARGO_PKG_VERSION_PATCH=50 }
:0: BUG:src/hir/hir.cpp:1090: Couldn't find component 0 of ::"gcc-0_3_50"::::ArchSpec#Device
Run Build- DEBUG: Compiler was terminated with signal 6
Run Build- DEBUG: See output/rustc-build/libgcc-0_3_50.hir_dbg.txt for the compiler output
BUILD FAILED

BUG:src/hir/hir.cpp:1090: Couldn't find component 0 of ::"gcc-0_3_50"::::ArchSpec#Device

When I’ve tried to remove entire function ios_flags and its caller, the build passed. However, then it failed on librustc_llvm:

Run Build- DEBUG: Building output/rustc-build/rustc_llvm_build - Missing
Run Build- Calling /home/jirutjak/aports/testing/rust-bootstrap/src/mrustc-1a16def28935548e29be0fe5a632e25c83045924/bin/mrustc rustc-1.19.0-src/src/librustc_llvm/build.rs --crate-name build --crate-type bin -o output/rustc-build/rustc_llvm_build -L output/rustc-build -L output --extern build_helper=output/rustc-build/libbuild_helper-0_1_0.hir --extern gcc=output/rustc-build/libgcc-0_3_50.hir
Run Build- DEBUG: Environment { CARGO_MANIFEST_DIR=/home/jirutjak/aports/testing/rust-bootstrap/src/mrustc-1a16def28935548e29be0fe5a632e25c83045924/rustc-1.19.0-src/src/librustc_llvm CARGO_PKG_VERSION=0.0.0 CARGO_PKG_VERSION_MAJOR=0 CARGO_PKG_VERSION_MINOR=0 CARGO_PKG_VERSION_PATCH=0 }
Run Build- Calling /home/jirutjak/aports/testing/rust-bootstrap/src/mrustc-1a16def28935548e29be0fe5a632e25c83045924/output/rustc-build/rustc_llvm_build
Run Build- DEBUG: Environment { CARGO_MANIFEST_DIR=/home/jirutjak/aports/testing/rust-bootstrap/src/mrustc-1a16def28935548e29be0fe5a632e25c83045924/rustc-1.19.0-src/src/librustc_llvm OUT_DIR=/home/jirutjak/aports/testing/rust-bootstrap/src/mrustc-1a16def28935548e29be0fe5a632e25c83045924/output/rustc-build/build_rustc_llvm TARGET= HOST= NUM_JOBS=1 OPT_LEVEL=2 DEBUG=0 PROFILE=release }
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error { repr: Os { code: 17, message: "File exists" } }', rustc-1.19.0-src/src/libcore/result.rs:861
Run Build- DEBUG: Compiler was terminated with signal 6
Run Build- DEBUG: See /home/jirutjak/aports/testing/rust-bootstrap/src/mrustc-1a16def28935548e29be0fe5a632e25c83045924/output/rustc-build/build_rustc_llvm.txt for the compiler output
BUILD FAILED

(I’ve added musl targets to src/main.cpp, src/trans/target.cpp and minicargo and applied our patches for musl to rustc-1.19.0. It works on x86_64 musl.)

Environment:

  • arch: aarch64
  • OS: Alpine Linux
  • libc: musl 1.1.19
  • toolchain: gcc 6.4.0
  • LLVM 4.0.0 (system-provided)

version tag for nicer build integration

I've successfully bootstrapped rust/cargo 1.20 and 1.21 using your compiler.
I'm extremely pleased, as this allows rust to be used in restrictive corporate environments.
Thank you very much for your work.

In order to integrate the bootstrap step, it would be nice, if this very usable state had a version number, so I don't have to resign to using a commit hash (which makes managers somehow uneasy).

Maybe you could even spare a version tag every other month? :-)

output/libs doesn't seem to exist

In several places, such as make test, there are references to like -L output/libs, but that folder definitely doesn't exist on my machine after building mrustc. In make test, it also has -L output, and output has lots of libraries in it, so that makes sense. I feel like -L output/libs might be an obsolete flag?

It would be nice if the README documented how to compile code using mrustc. After observing how the Makefile is able to use mrustc, I figured it out, and it's bascially just

mrustc hello.rs -L output

once all the paths are adjusted as appropriate.

I have not been able to figure out minicargo... it seems to just do nothing, and the output is always either completely empty, Usage: minicargo <package dir>, or EXCEPTION: Unable to open file 'Cargo.toml'. I haven't been able to get it to do anything else.

enum C type conversion is wrong?

rustc-1.19.0-src/src/vendor/log/src/lib.rs contains:

#[repr(usize)]
#[derive(Copy, Eq, Debug)]
pub enum LogLevelFilter {

mrustc seems to define usize as uintptr_t, but mrustc converts this to:

struct e__ZN10log$$0_3_714LogLevelFilter {
    unsigned int TAG;
};

usize is correctly converted to uintptr_t later on, in ::"log-0_3_7"::max_log_level, resulting in a memcpy of 64 bits (uintptr_t size on 64-bit platforms) to a data structure that is only unsigned int (32-bit).

Disclaimer: I don't know Rust, so double-check my assumptions.

Implement derive on unions

In trying to build a simple ESP8266 firmware example, I am unable to compile my crate of generated bindings to the Arduino library because it depends on deriving Copy on unions:

:0: BUG:src/expand/derive.cpp:2186: TODO: handle - Handle #[derive] for other item types - Union

Warn but ignore unrecognized manifest keys

This is the approach Cargo takes to best support using an old Cargo to compile new crates that use Cargo.toml manifest keys introduced in a later version of Cargo.

I have hit this in two unrecognized keys so far.

EXCEPTION: Unknown key `publish` in [package]
TODO: Unknown manifest section example
Aborted (core dumped)

In both cases it would have worked to just ignore the key and keep going.

Xtensa (ESP8266/ESP32) support

I'd love to at least attempt to add support for the Xtensa used in the ESP8266/32 WiFi chips, as it will probably be a long time until LLVM gains support for it. What would be involved in adding another target? It looks like most of the changes would involve additions to src/trans/target.cpp, but are there any gotchas to watch out for?

Alignment and sizes

This issue collects the alignment of struct members on gcc.

The following program has been run:

#define _GNU_SOURCE
#include <stdio.h>
#include <stdint.h>
#include <stddef.h>

struct foo {
        unsigned char a;
        uint16_t b;
};

int main() {
        struct foo f;
        printf("b_offset = %zu\n", offsetof(struct foo, b));
        printf("b_size = %zu\n", sizeof(f.b));
        return 0;
}

On armhf, this results in: b_offset = 2, b_size = 2.

Then I modified it accordingly to get:

armhf (both gcc 7.3.0 and gcc 5.4.0):

Type         Alignment/Bytes  Size/Bytes
int8_t       1                1
int16_t      2                2
int32_t      4                4
int64_t      8                8
__int128     not supported
uint8_t      1                1
uint16_t     2                2
uint32_t     4                4
uint64_t     8                8
float        4                4
double       8                8
long double  8                8
size_t       4                4
off_t        4                4
void*        4                4

x86_64 (gcc 7.3.0):

Type         Alignment/Bytes  Size/Bytes
int8_t       1                1
int16_t      2                2
int32_t      4                4
int64_t      8                8
__int128     16               16
uint8_t      1                1
uint16_t     2                2
uint32_t     4                4
uint64_t     8                8
float        4                4
double       8                8
long double  16               16
size_t       8                8
off_t        8                8
void*        8                8

i686 (gcc 7.3.0):

Type         Alignment/Bytes  Size/Bytes
int8_t       1                1
int16_t      2                2
int32_t      4                4
int64_t      4                8
__int128     not supported
uint8_t      1                1
uint16_t     2                2
uint32_t     4                4
uint64_t     4                8
float        4                4
double       4                8
long double  4                12
size_t       4                4
off_t        4                4
void*        4                4

Cannot compile std on rust 1.19.0

Hello! I'm trying to compile rust following the instructions on the Readme. When running

make -f minicargo.mk

I'm getting the following error:

BUILDING std from std v0.0.0 with features []
Calling /home/christian/Workspace/mrustc/bin/mrustc rustc-1.19.0-src/src/libstd/lib.rs --crate-name std --crate-type rlib -g -O -o output/libstd.hir -L output -l dl -l rt -l pthread --extern alloc=output/liballoc.hir --extern alloc_system=output/liballoc_system.hir --extern panic_abort=output/libpanic_abort.hir --extern collections=output/libcollections.hir --extern core=output/libcore.hir --extern libc=output/liblibc.hir --extern rand=output/librand.hir --extern compiler_builtins=output/libcompiler_builtins.hir --extern std_unicode=output/libstd_unicode.hir --extern unwind=output/libunwind.hir --extern rustc_asan=output/librustc_asan.hir --extern rustc_lsan=output/librustc_lsan.hir --extern rustc_msan=output/librustc_msan.hir --extern rustc_tsan=output/librustc_tsan.hir
DEBUG: Environment { OUT_DIR=/home/christian/Workspace/mrustc/output/build_std CARGO_MANIFEST_DIR=/home/christian/Workspace/mrustc/rustc-1.19.0-src/src/libstd CARGO_PKG_VERSION=0.0.0 CARGO_PKG_VERSION_MAJOR=0 CARGO_PKG_VERSION_MINOR=0 CARGO_PKG_VERSION_PATCH=0 }
:511: warning0:Unknown cfg() param 'target_vendor'
:511: warning0:Unknown cfg() param 'target_vendor'
rustc-1.19.0-src/src/libstd/sys/unix/net.rs:94: warning0:Unknown cfg() param 'target_vendor'
output/libstd.hir.o.c:49611:9: error: ‘_ZRK$aLfn_1_$Rs__ZN3std9panicking9PanicInfo_$T0_as__ZN4core3ops5FnMut$aL$T1_$Rs__ZN3std9panicking9PanicInfo$aR$aRcall_mut’ undeclared here (not in a function); did you mean ‘_ZRK$aLfn_1_$Rs__ZN3std9panicking9PanicInfo_$T0_as__ZN4core3ops2Fn$aL$T1_$Rs__ZN3std9panicking9PanicInfo$aR$aRcall’?
  (void*)_ZRK$aLfn_1_$Rs__ZN3std9panicking9PanicInfo_$T0_as__ZN4core3ops5FnMut$aL$T1_$Rs__ZN3std9panicking9PanicInfo$aR$aRcall_mut
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         _ZRK$aLfn_1_$Rs__ZN3std9panicking9PanicInfo_$T0_as__ZN4core3ops2Fn$aL$T1_$Rs__ZN3std9panicking9PanicInfo$aR$aRcall
C Compiler failed to execute
DEBUG: Compiler was terminated with signal 6
DEBUG: See output/libstd.hir_dbg.txt for the compiler output
BUILD FAILED
make: *** [minicargo.mk:42: output/libstd.hir] Error 1

I've also tried to run the following command, ending with the same output:

make -f minicargo.mk RUSTC_CHANNEL=stable RUSTC_VERSION=1.19.0 OVERRIDE_SUFFIX=-linux

Spare rules left after typecheck stabilised

struct Struct;

trait Trait {
    type Assoc;
}

impl Trait for Struct {
    type Assoc = Struct;
}

fn f<S>(_: &S) where S: Trait<Assoc = S> {}

fn g() {
    f(&Struct);
}
repro.rs:14: warning0:Spare Rule - &_/*3*/ := &::"repro-0_1_0"::Struct
repro.rs:14: warning0:Spare Rule - _/*3*/ = < _/*3*/ as ::"repro-0_1_0"::Trait >::Assoc
repro.rs:16: BUG:src/hir_typeck/expr_cs.cpp:6371: Spare rules left after typecheck stabilised

This is minimized from trying to compile calls to this function.

Building rustc 1.19.0 fails

DEBUG: Building output/libpkg_config.hir - Missing
Calling /usr/bin/mrustc src/vendor/pkg-config/src/lib.rs --crate-name pkg_config --crate-type rlib -g -O -o output/libpkg_config.hir -L output
DEBUG: Environment { CARGO_MANIFEST_DIR=/var/tmp/portage/dev-lang/rust-1.19.0/work/rustc-1.19.0-src/src/vendor/pkg-config CARGO_PKG_VERSION=0.3.9 }
:0: error:0:Unable to locate crate 'std'
DEBUG: Compiler was terminated with signal 6
BUILD FAILED

Full build log: https://gist.github.com/1a63d123407667485f09e794c6122829

(let's keep this issue open until the build completes?)

make -C run_rustc fails to build prefix/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore.rlib with a panic from rustc

Previously reported in #63.

[RUSTC] -o prefix/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore.rlib
Command terminated by signal 6
#0  0x00007ffff6b923f8 in raise () from /lib64/libc.so.6
#1  0x00007ffff6b93ffa in abort () from /lib64/libc.so.6
#2  0x00000000006ff569 in _ZN11panic_abort3$H05abort () at output/libpanic_abort.hir.o.c:91
#3  0x00000000006ff599 in __rust_start_panic (arg0=<optimized out>, arg1=<optimized out>) at output/libpanic_abort.hir.o.c:120
#4  0x0000000000582b59 in rust_panic (arg0=...) at output/libstd.hir.o.c:63518
#5  0x0000000000583a75 in _ZN3std9panicking20rust_panic_with_hook (arg0=..., arg1=arg1@entry=0x7ffff692ed80) at output/libstd.hir.o.c:63707
#6  0x0000000000583acb in _ZN3std9panicking11begin_panic$aL_ZN11collections6string6String$aR (arg0=..., arg1=arg1@entry=0x7ffff692ed80) at output/libstd.hir.o.c:63189
#7  0x0000000000583b45 in _ZN3std9panicking15begin_panic_fmt (arg0=arg0@entry=0x7ffff692edb0, arg1=arg1@entry=0x7ffff692ed80) at output/libstd.hir.o.c:63246
#8  0x0000000000583d2e in rust_begin_unwind (arg0=..., arg1=..., arg2=<optimized out>) at output/libstd.hir.o.c:63489
#9  0x0000000000bcbc9e in _ZN4core9panicking9panic_fmt (arg0=..., arg1=<optimized out>) at output/rustc-build/librustc.hir.o.c:459090
#10 0x0000000000c032d5 in _ZN4core6result13unwrap_failed$aL_ZN11collections6string6String$aR (arg1=..., arg0=...) at output/rustc-build/librustc.hir.o.c:467165
#11 _ZRI$aL_ZN4core6result6Result$aL_ZN5rustc2ty6layout5Align$C_ZN11collections6string6String$aR$aR6unwrap (arg0=...) at output/rustc-build/librustc.hir.o.c:16244
#12 0x0000000000d7f35a in _ZRI$aL_ZN5rustc2ty6layout6Struct$aR3new (arg0=0x7ffff69362a0, arg1=arg1@entry=0x7ffff692f5c0, arg2=<optimized out>, arg3=..., arg4=0x7fffde89bee0)
    at output/rustc-build/librustc.hir.o.c:1262919
#13 0x0000000000f28034 in _ZRI$aL_ZN5rustc2ty6layout6Layout$aR16compute_uncached (arg0=..., arg1=..., arg2=arg2@entry=0x7fffde89bee0) at output/rustc-build/librustc.hir.o.c:1257924
#14 0x0000000000f29b74 in _ZN5rustc2ty4util10layout_raw (arg0=..., arg1=...) at output/rustc-build/librustc.hir.o.c:654812
#15 0x0000000000cb5477 in _ZRK$aL_ZN5rustc13closure_I_703$aL_ZN5rustc2ty4maps7queries10layout_raw$Cfn_1_$Rs__ZN4core6result6Result$aL$Rs__ZN5rustc2ty6layout6Layout$C_ZN5rustc2ty6layout11LayoutError$aR__ZN4core6result6Result$aL$Rs__ZN5rustc2ty6layout6Layout$C_ZN5rustc2ty6layout11LayoutError$aR$C_ZN4core6result6Result$aL$Rs__ZN5rustc2ty6layout6Layout$C_ZN5rustc2ty6layout11LayoutError$aR$aR_as__ZN4core3ops2Fn$aL$T0$aR$aR4call (arg0=arg0@entry=0x7ffff692fda0, arg1=...) at output/rustc-build/librustc.hir.o.c:1917371
#16 0x0000000000d8cc51 in _ZRI$aL_ZN5rustc2ty7context6TyCtxt$aR11cycle_check$aL_ZN5rustc13closure_I_703$aL_ZN5rustc2ty4maps7queries10layout_raw$Cfn_1_$Rs__ZN4core6result6Result$aL$Rs__ZN5rustc2ty6layout6Layout$C_ZN5rustc2ty6layout11LayoutError$aR__ZN4core6result6Result$aL$Rs__ZN5rustc2ty6layout6Layout$C_ZN5rustc2ty6layout11LayoutError$aR$C_ZN4core6result6Result$aL$Rs__ZN5rustc2ty6layout6Layout$C_ZN5rustc2ty6layout11LayoutError$aR$aR$C_ZN4core6result6Result$aL$Rs__ZN5rustc2ty6layout6Layout$C_ZN5rustc2ty6layout11LayoutError$aR$aR (arg0=...,
    arg1=..., arg2=..., arg3=...) at output/rustc-build/librustc.hir.o.c:1236010
#17 0x0000000000d8d17b in _ZRI$aL_ZN5rustc2ty4maps7queries10layout_raw$aR12try_get_with$aLfn_1_$Rs__ZN4core6result6Result$aL$Rs__ZN5rustc2ty6layout6Layout$C_ZN5rustc2ty6layout11LayoutError$aR__ZN4core6result6Result$aL$Rs__ZN5rustc2ty6layout6Layout$C_ZN5rustc2ty6layout11LayoutError$aR$C_ZN4core6result6Result$aL$Rs__ZN5rustc2ty6layout6Layout$C_ZN5rustc2ty6layout11LayoutError$aR$aR (arg0=..., arg1=..., arg2=...,
    arg3=arg3@entry=0xd7cb30 <_ZRK$aL_ZN4core6result6Result$aL$Rs__ZN5rustc2ty6layout6Layout$C_ZN5rustc2ty6layout11LayoutError$aR_as__ZN4core5clone5Clone$aR5clone>)
    at output/rustc-build/librustc.hir.o.c:1291556
#18 0x0000000000d8d465 in _ZRI$aL_ZN5rustc2ty4maps7queries10layout_raw$aR7try_get (arg0=..., arg1=..., arg2=...) at output/rustc-build/librustc.hir.o.c:1291119
#19 0x0000000000e2d974 in _ZRI$aL_ZN5rustc2ty4maps8TyCtxtAt$aR10layout_raw (arg0=..., arg1=...) at output/rustc-build/librustc.hir.o.c:1268754
#20 0x0000000000ecb70d in _ZRI$aL_ZN5rustc2ty3TyS$aR6layout (arg0=0x7fffde89bee0, arg1=..., arg2=...) at output/rustc-build/librustc.hir.o.c:1211437
#21 0x0000000000f1f161 in _ZRI$aL_ZN5rustc2ty6layout12SizeSkeleton$aR7compute (arg0=0x7fffde89bee0, arg1=..., arg2=...) at output/rustc-build/librustc.hir.o.c:1261543
#22 0x0000000000f1f833 in _ZRI$aL_ZN5rustc6middle11intrinsicck11ExprVisitor$aR15check_transmute (arg0=arg0@entry=0x7ffff6930e40, arg1=..., arg2=0x7fffde89bee0, arg3=0x7ffff2f97c30)
    at output/rustc-build/librustc.hir.o.c:1134876
#23 0x0000000000f20177 in _ZRK$aL_ZN5rustc6middle11intrinsicck11ExprVisitor_as__ZN5rustc3hir10intravisit7Visitor$aR10visit_expr (arg0=arg0@entry=0x7ffff6930e40, arg1=0x7fffd8dd5900)
    at output/rustc-build/librustc.hir.o.c:2054551
#24 0x0000000000f23f4c in _ZN5rustc3hir10intravisit9walk_expr$aL_ZN5rustc6middle11intrinsicck11ExprVisitor$aR (arg0=arg0@entry=0x7ffff6930e40, arg1=arg1@entry=0x7fffd8dd5d00)
    at output/rustc-build/librustc.hir.o.c:494202
#25 0x0000000000f20182 in _ZRK$aL_ZN5rustc6middle11intrinsicck11ExprVisitor_as__ZN5rustc3hir10intravisit7Visitor$aR10visit_expr (arg0=arg0@entry=0x7ffff6930e40, arg1=0x7fffd8dd5d00)
    at output/rustc-build/librustc.hir.o.c:2054452
#26 0x0000000000f23871 in _ZN5rustc3hir10intravisit10walk_block$aL_ZN5rustc6middle11intrinsicck11ExprVisitor$aR (arg0=0x7ffff6930e40, arg1=0x7fffd8dd5d70)
    at output/rustc-build/librustc.hir.o.c:482718
#27 0x0000000000f23c78 in _ZN5rustc3hir10intravisit9walk_expr$aL_ZN5rustc6middle11intrinsicck11ExprVisitor$aR (arg0=arg0@entry=0x7ffff6930e40, arg1=arg1@entry=0x7fffd8e220e0)
    at output/rustc-build/librustc.hir.o.c:493849
#28 0x0000000000f20182 in _ZRK$aL_ZN5rustc6middle11intrinsicck11ExprVisitor_as__ZN5rustc3hir10intravisit7Visitor$aR10visit_expr (arg0=arg0@entry=0x7ffff6930e40,
    arg1=arg1@entry=0x7fffd8e220e0) at output/rustc-build/librustc.hir.o.c:2054452
#29 0x0000000000f2026c in _ZN5rustc3hir10intravisit9walk_body$aL_ZN5rustc6middle11intrinsicck11ExprVisitor$aR (arg0=arg0@entry=0x7ffff6930e40, arg1=arg1@entry=0x7fffd8e220d0)
    at output/rustc-build/librustc.hir.o.c:484363

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.