Sébastien Marie <semarie-open...@latrappe.fr> writes:

> Hi,
>
> I am currently working to port rustc to openbsd (amd64).

Awesome!

>
> I have wrote a compatibility layer for openbsd (using some part of
> http://www.ntecs.de/blog/2014/07/29/rust-ported-to-dragonflybsd/ and
> https://github.com/qbit/rust-cross-openbsd), and I am able to
> cross-compile a rustc openbsd-binary from linux.

My fork was a pretty sad attempt at getting it ported.. I stopped
with the lack of segmented stacks. That said Dave Huseby made it much
further: https://github.com/dhuseby/rust-cross-openbsd !

IIRC he ran into another issue with linking.. and is currently working
on https://github.com/dhuseby/rust-cross-bitrig .

He would probably be the person to talk to about furthering the OpenBSD
port!

>
> I have done lot of rewrite for have a more valid openbsd support in
> rustc. For explain to not-rustc-dev-aware persons: rustc don't used
> header files (.h). It needs to rewriting them in rustc-language, and use
> that for FFI calls. It is methods definition, types definition (size,
> struct members...).
>
> And as openbsd isn't same as freebsd or dragonfly, just adding
> conditional-compilation at same places of freebsd/dragonfly isn't
> enought.
>
>
> The rustc code is here: https://github.com/semarie/rust/tree/openbsd,
> and for compilation I mainly take inspiration from
> http://github.jfet.org/Rust_cross_bootstrapping.html.
>
> My build framework is somehow fragile: it use shared filesystem between
> a linux (debian wheezy) and an openbsd (openbsd-current, somewhere at
> starting 5.7-BETA). For openbsd target, the objects files are build on
> linux, and linking (using remote-command) on openbsd (modulo some parts
> based on C code, whole compiled under openbsd, like LLVM, compiler-rt,
> libbacktrace...).
>
> As result, the rustc openbsd-binary is mainly fonctionnal: I am able to
> build simples rustc programs (like hello-world.hs, or guess.rs [from
> rustc guide]).
>
> So I started to build rustc it-self, fully under openbsd. The current
> status is the build isn't complete because of random panic or coredump
> (more details below).
>
> The current goal is to have a working rustc binary compiled from
> openbsd, and next check it with the rustc testing framework.
>
> Some workarounds/problems:
>  - I compile without jemalloc (the jemalloc "make check" crash
>    systematically. The issue wasn't investigated as jemalloc seems to be
>    optional)
>  
>  - I don't implement 'load_self' function which live under
>    'libstd/sys/unix/os.rs'. The function should return the filepath of
>    the current running program (and it isn't trivial as there are
>    possibles races).
>
>    As result, rustc *must* have a --sysroot argument to work, else it
>    would panic (and so I hack the build process to pass the argument).
>    Note this build hack isn't in my github repository.
>
>> mk/main.mk
>> -EXTRAFLAGS_STAGE$(1) = $$(RUSTFLAGS_STAGE$(1))
>> +EXTRAFLAGS_STAGE$(1) = --sysroot $$(HROOT$(1)_H_$(3)) 
>> $$(RUSTFLAGS_STAGE$(1))
>
>  - under openbsd, it seems rustc couldn't use ports/llvm.
>  
>    ports/llvm annonce it-self as 3.5, but directory structure is
>    something between 3.4.2 et 3.5. and even if I hack the #include in
>    src/rustllvm, I have compilation errors...
>    
>    As result, I currently use the llvm version provided with rustc, and
>    so need to compile the embeded llvm version before compile rustc.
>
>    It is ok for now, but when rustc would work enought to be packaged,
>    it should be investigated...
>
>  - for coredump, there are double-free and coredump that occurs
>    generally in thread code. I think the openbsd-layer of rustc isn't
>    fully correct.
>
>  - sometimes, panic randomly occurs (rustc detect itself a problem and
>    abort). Generally it is in checking of args for FFI ('\0' char in
>    middle of CString for example). So could be related to
>    openbsd-specific code in rustc.
>
>  - sometimes, rustc enter in infinite-loop (but it stuck in a wait, not
>    a busy loop). It is generally in spawing... so it may be a race in
>    waiting the process to ending ? Seems related to spawning too...
>
>
> In conclusion, I am able to build rustc until processing
> librustc_llvm.rlib (librustc_llvm.so is ok).
>
> And I am currently blocking by thread-related coredump (or
> infinite-waiting). 
>
> For how I understand the build system of rustc, building
> src/librustc_llvm need to heavy use of spawning, for construct the rlib
> file (an object archive, if I understand well), as it take objects files
> from LLVM libraries (so a lot of libraries). So I hit theses bugs each
> time (but never at same place...) I try to build it.
>
> So I am in a linuxBuild-openbsdBuild-correctOpenbsdRustcSupport loop...
> (and a full linuxBuild is something like 90min compile time).
>
> Review of the rustc openbsd specific code are welcome... or any others
> ideas :)
>
> Thanks reading.

Reply via email to