Qemu static configure error (thread local storage) - arm

I'm trying to compile Qemu for this target in a static way : {arm-linux-user, armeb-linux-user, arm-softmmu}.
here is this configure command I'm using :
./configure --target-list="arm-linux-user armeb-linux-user arm-softmmu" --disable-werror --enable-debug --static
When I'm executing this command I got the following error :
C++ compiler c++ does not work with C compiler cc Disabling C++
specific optional code
ERROR: Your compiler does not support the __thread specifier for
Thread-Local Storage (TLS). Please upgrade to a version that does.
Or, my cc version is 5.1.1 so this is quite new :
[lionel#localhost qemu]$ cc -v
Utilisation des specs internes.
COLLECT_GCC=cc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/5.1.1/lto-wrapper
Cible : x86_64-redhat-linux
Configuré avec: ../configure --enable-bootstrap --enable-languages=c,c++,objc,obj-c++,fortran,ada,go,lto --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --disable-libgcj --with-isl --enable-libmpx --enable-gnu-indirect-function --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
gcc version 5.1.1 20150618 (Red Hat 5.1.1-4) (GCC)
I can compile it normally without the "--static" argument. I need to compile it in static way as I am trying to chroot into a filesystem where binaries are ELF arm executable..
If it is not possible I could possibly use qemu-system-arm to emulate to board.

Configure will also produce this error message if your linker is broken (ie trying to compile a .c program to an executable doesn't work), because the TLS check happens to be the first one which tries to do that -- in this case it will print a misleading error message. In this case your compiler is definitely new enough to handle __thread, so you should check whether your linker works OK. Looking in config.log will show all the programs QEMU's configure script tried to run and their output.
(I just submitted a patch -- http://patchwork.ozlabs.org/patch/548123/ -- which will result in a less confusing warning if your linker doesn't work.)

Related

__builtin_strncpy warning from Kernel Compile

I recently tried to compile Kernel (4.18.1) on top of CentOS 8.5 system.
When Kernel build progress, I saw many message like
./include/linux/string.h:246:9: warning: ‘__builtin_strncpy’ output truncated before terminating nul copying as many bytes from a string as its length [-Wstringop-truncation]
return __builtin_strncpy(p, q, size);
I originally thought somewhere Kernel has Makefile including [-Wstringop-truncation] but it seems not.
And this is output of gcc -v in my CentOS 8.5 system.
# gcc -v | grep stringtop
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,lto --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --with-isl --disable-libmpx --enable-offload-targets=nvptx-none --without-cuda-driver --enable-gnu-indirect-function --enable-cet --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
Thread model: posix
gcc version 8.5.0 20210514 (Red Hat 8.5.0-10) (GCC)
If someone can explain why I see this message and how to remove it, it would be great.

configure: error: cannot run C compiled programs

I'm trying to install different software onto my Raspberry Pi with Debian Wheezy OS. When I run try to configure software I'm trying to install I get this output
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... configure: error: in 'directory of where I'm installing the software'
configure: error: cannot run C compiled programs.
If you meant to cross compile, use '--host'.
See config.log' for more details
So then I check the config log and it basically says the same thing, the only difference is I see there was a segfault when checking whether cross compiling:
configure:3547: checking for suffix of executables
configure:3554: /usr/bin/gcc -o conftest -Wno-long-long conftest.c >&5
configure:3558: $? = 0
configure:3580: result:
configure:3602: checking whether we are cross compiling
configure:3610: /usr/bin/gcc -o conftest -Wno-long-long conftest.c >&5
configure:3614: $? = 0
configure:3621: ./conftest
./configure: line 3623: 3679 Segmentation fault ./conftest$ac_cv_exeext
configure:3625: $? = 139
configure:3632: error: in `/usr/local/src/VALGRIND/valgrind-3.10.1':
configure:3634: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details
This error has come up twice now. Once when trying to install Valgrind and once when trying to install libusb.
The output with gcc -v is this:
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/arm-linux-gnueabihf/4.6/lto-wrapper
Target: arm-linux-gnueabihf
Configured with: ../src/configure -v --with-pkgversion='Debian 4.6.3-14+rpi1' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable- languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --disable-sjlj-exceptions --with-arch=armv6 --with-fpu=vfp --with-float=hard --enable-checking=release --build=arm-linux-gnueabihf --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf
Thread model: posix
gcc version 4.6.3 (Debian 4.6.3-14+rpi1)
On CoreOS, solved the problem with.
install.packages('rgdal', type = "source", configure.args='--host=host')
The problem here has been resolved by:
export PATH=/path/to/gcc-4.9.2/bin/:$PATH
export LD_LIBRARY_PATH=/path/to/gcc-4.9.2/lib64/:$LD_LIBRARY_PATH
./configure --prefix=/path/to/ --host=arm
Hope this will help you.
It is an issue with /tmp directory. Just append this to your pip command: --build ./ and rerun it.
./ is current working directory.
I got this exact error. When I looked in config.log I saw the message:
fatal error: sys/cdefs.h: No such file or directory
To fix this, I ran:
sudo apt-get install libc6-dev
I could then configure and compile my program.

MATLAB(linux) cannot find the gcc

I try to compile in MATALAB, but it seems that the MATLAB cannot find the gcc:
Error using mex
No supported compiler or SDK was found. For options, visit
http://www.mathworks.com/support/compilers/R2014a/glnxa64.
Error in compile (line 439)
mex(args{:});
>> mex -setup
MEX configured to use 'gcc' for C language compilation.
Warning: The MATLAB C and Fortran API has changed to support MATLAB
variables with more than 2^32-1 elements. In the near future
you will be required to update your code to utilize the
new API. You can find more information about this at:
http://www.mathworks.com/help/matlab/matlab_external/upgrading-mex-files-to-use-64-bit-api.html.
To choose a different language, select one from the following:
mex -setup C++
mex -setup FORTRAN
But I have already installed the gcc using apt-get install gcc, and type the gcc -v can get the following information:
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.8/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.8.2-19ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs --enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.8 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.8 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-libmudflap --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.8.2 (Ubuntu 4.8.2-19ubuntu1)
How can I solve this problem?
converting my comment into this answer:
The error message tells you to go to http://mathworks.com/support/compilers/R2014a/glnxa64, which lists gcc 4.7.x as a supported compiler, but you have 4.8.2.
So you need to install GCC 4.7. On Ubuntu this can be done using:
sudo apt-get install gcc-4.7

LLVM missing linker and can't compile the lld (llvm linker)

I want to build a compiler to a new target and I choose llvm. As far as I understand, I can use the clang project as a front end and llvm as a back end. I can get .o files out of the llc (part of the llvm). now I need to link them all into executable. I tried using lld project but it failed compiling with the error :
Desktop/llvm_project/llvm/lib/Target/ARM/ARMISelLowering.cpp: In member function ‘llvm::Instruction* llvm::ARMTargetLowering::makeDMB(llvm::IRBuilder<>&, llvm::ARM_MB::MemBOpt) const’:
Desktop/llvm_project/llvm/lib/Target/ARM/ARMISelLowering.cpp:11000:73: error: could not convert ‘{(& Builder)->llvm::IRBuilder<>::<anonymous>.llvm::IRBuilderBase::getInt32(15u), (& Builder)->llvm::IRBuilder<>::<anonymous>.llvm::IRBuilderBase::getInt32(0u), (& Builder)->llvm::IRBuilder<>::<anonymous>.llvm::IRBuilderBase::getInt32(0u), (& Builder)->llvm::IRBuilder<>::<anonymous>.llvm::IRBuilderBase::getInt32(7u), (& Builder)->llvm::IRBuilder<>::<anonymous>.llvm::IRBuilderBase::getInt32(10u), (& Builder)->llvm::IRBuilder<>::<anonymous>.llvm::IRBuilderBase::getInt32(5u)}’ from ‘<brace-enclosed initializer list>’ to ‘llvm::ArrayRef<llvm::Value*>’
Builder.getInt32(10), Builder.getInt32(5)};
^
make[2]: *** [lib/Target/ARM/CMakeFiles/LLVMARMCodeGen.dir/ARMISelLowering.cpp.o] Error 1
make[1]: *** [lib/Target/ARM/CMakeFiles/LLVMARMCodeGen.dir/all] Error 2
make: *** [all] Error 2
so I have several question cause I think I am missing something :
if I don't have binutils for the new target, how should I use the llvm project ? - they create they great project...but without the final piece that actually create running files ?! what should I use as a linker ?
anyone encountered this lld build error and solved it ?
uname -a
Linux my_name-Inspiron-3521 3.13.0-35-generic #62-Ubuntu SMP Fri Aug
15 01:58:42 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
gcc -v
Using built-in specs. COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.8/lto-wrapper
Target: x86_64-linux-gnu Configured with: ../src/configure -v
--with-pkgversion='Ubuntu 4.8.2-19ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs --enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.8 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.8 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-libmudflap --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix gcc version 4.8.2 (Ubuntu 4.8.2-19ubuntu1)
The error you are encountering is in llvm itself, not lld. I'm not seeing that error on the buildbots, so I recommend updating your source tree.
As for binutils, llvm does not currently provide a complete replacement for them. This is being worked on, but it will be a while before it's completed. For now I recommend using gnu binutils with either ld or gold as the linker.

What is this GCC error on Linux, and how do I solve it? gcc: internal compiler error: Illegal instruction (program as)

I type gcc hello.c and this appears:
gcc: internal compiler error: Illegal instruction (program as)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.6/README.Bugs> for instructions.
hello.c is just:
int main()
{
return 0;
}
I can't think of any way to make it simpler! (The same happened with printf in there.)
So: how do you fix this? I'm on Raspian, on Raspberry Pi.
Edit
gcc -v gives
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/arm-linux-gnueabihf/4.6/lto-wrapper
Target: arm-linux-gnueabihf
Configured with: ../src/configure -v --with-pkgversion='Debian 4.6.3-14+rpi1' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --disable-sjlj-exceptions --with-arch=armv6 --with-fpu=vfp --with-float=hard --enable-checking=release --build=arm-linux-gnueabihf --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf
Thread model: posix
gcc version 4.6.3 (Debian 4.6.3-14+rpi1)
No I didn't install it.
As for updates, sudo apt-get install gcc gives
Reading package lists... Done
Building dependency tree
Reading state information... Done
gcc is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Yes, you can run as, it says Illegal instruction with no arguments.
I have no idea what swap space is.
gcc -O0 -g hello.c gives the same error.
gcc does not recognise --enable-debug.
Got it! I uninstalled gcc, installed gcc-4.7, and ... nothing.
I cleared out the end of gcc-4.6 and re-ran sudo apt-get install gcc-4.7 and ... nothing.
I updated binutils and ... it worked!
So, as didn't appear to be affected by updating GCC, but updating it more directly did it for me.
(It was from 2.22-7.1 to 2.22-8, if that helps anyone.)
I can only shed some light on the error message:
gcc: internal compiler error: Illegal instruction (program as)
gcc does several things when compiling. It first translates your C program into assembler and then converts the assembler into machine code.
The name of the assembler program with gcc is just as. So the error message tells you, that running the assembler fails, because the assembler executable contains an illegal instruction.
This might really be an hardware error, meaning that the executable of the assembler is broken.
To check:
Does gcc -S hello.c work ? That should create a "hello.s" containing the C code compiled to assembler
You might try with gcc -v -c hello.c to find out what happens exactly.
Found on raspberryPi forums:
Grabbed the sources and tried a cross-compile on an x86-64 box for a generic arm target. Something inside filter/hq2x.cpp is causing GCC to go nuts and consume memory & swap, so I wouldn't be at all surprised if it triggers a fatal error on a Pi. Some sources suggest that it is the compiler's (cc1plus) internal stack overflowing.
One possible fix is to run the configure script with --enable-debug - This should reduce optimization to a minimum and avoid stack overflows at the expense of increased binary size.
So you can try to set compiler flags to
-O0 -g
and check whether it helps.
Got similar problem.
But it happened after move of VirtualBox image (with Xubuntu 16.04/gcc-5) from Haswell based machine to Sandy Bridge. Problem was somewhere in build-essential / gcc / binutils packages. I reinstalled all of them (with apt remove and apt install - no oneshot reinstall) - it helped.
Try updating the compiler and try
sudo apt-get install build-essential
That might solve the problem.

Resources