[cfarm-users] Modern GCC for mips64 machines

Zach van Rijn me at zv.io
Sat Oct 20 19:34:35 CEST 2018


On Sat, 2018-10-20 at 08:15 -0400, Jeffrey Walton via cfarm-
users wrote:
> ...
> OK, thanks. So I was able to compile using the instruction but
> the resulting program is a dud:
> 
>     $ ./test.exe
>     -bash: ./test.exe: No such file or directory
> 
> The file is present, its executable, its mips64, etc.

Right. These toolchains are built using 'musl' libc, not GNU
libc ('glibc') and therefore you'd want to compile them
statically (note the '-static' flag). If you want to dynamically
link your programs, you _can_ choose to build musl from source
(it's pretty quick) and use its linker.

I rebuilt all of the toolchains yesterday with some updates
(binutils 2.31.1, latest musl from git, and new kernel headers)
as well as added that '. --> usr' symlink by default. So you
should not encounter that issue in the future.

$ cat ./test.c
#include <stdio.h>
#include <wchar.h> /* to show that symlink works */
int main (void) { printf("it works\n"); return 0; }

To build your program statically:

$ export PATH="$HOME/mips64-linux-musl-native/bin:$PATH"

$ gcc -static -o test test.c
$ file test
test: ELF 64-bit MSB executable, MIPS, MIPS-III version 1
(SYSV), statically linked, with unknown capability
0x410000000f676e75 = 0x1000000070401, not
stripped                                                   
$ ./test
it works

Alternatively, you can download and compile musl from source, on
this MIPS machine:

$ wget http://www.musl-libc.org/releases/musl-1.1.20.tar.gz
$ tar -xf musl-1.1.20.tar.gz
$ cd      musl-1.1.20
$ CC=$HOME/mips64-linux-musl-native/bin/gcc ./configure \
    --prefix=$HOME/musl
$ make -j$(nproc)
$ make install

$ gcc -o test_dyn test.c
$ file test_dyn 
test_dyn: ELF 64-bit MSB executable, MIPS, MIPS-III version 1
(SYSV), dynamically linked (uses shared libs), with unknown
capability 0x410000000f676e75 = 0x1000000070401, not stripped
$ ./musl/lib/libc.so ./test_dyn 
it works

> ...
> This is not surprising and probably causing the unusual
> result. I think this is probably a dead end.

Nope; works as intended. As you can see above, both static and
dynamic programs are supported. The latter is a little messy.
Static programs (like the toolchain itself) can be transferred
to any almost other machine with compatible hardware.

> 
> Let me send a request to cfarm-admins to see if someone who is
> experienced has time to build a compiler.
> 
> Thanks again for the help.
> 
> Jeff
> _______________________________________________
> cfarm-users mailing list
> cfarm-users at lists.tetaneutral.net
> https://lists.tetaneutral.net/listinfo/cfarm-users




More information about the cfarm-users mailing list