AVR32/GCC Linker warning: input is not relaxable - gcc

I am trying to compile an AVR32 program with GCC 3.4.2 and getting the following linker warning:
input is not relaxable
Could someone explain what that warning means?
Linker flags: -Wl,--start-group -Wl,--end-group -Wl,--gc-sections -mpart=uc3c0512c -Wl,--relax -Wl,-e,_trampoline

From Atmel
Linker relaxing is enabled in the linker by passing the ‘—relax’
option to the linker. If using GCC as a frontend for the linker, this
option is automatically passed to the linker when using ‘-O2’ or
‘-O3’ or explicitly using the ‘-mrelax’ option. Marking the output
objects from GCC as relaxable is done by giving the assembler the
‘--linkrelax’ option. This option is automatically passed on to the
assembler from GCC when using ‘-O2’ or ‘-O3’ or explicitly using the
‘-mrelax’ option.
Perhaps you didn't pass the needed options to the assembler for the --relax option to work in the linker.

Related

setting g++ mode to C++11

I am trying to build cmake source, which requires C++11.
The build halts and apparently the complaint is that C++11 is not detected. The g++ mode is actually set to -std=gnu++17
This is part of the console log
---------------------------------------------
CMake 3.18.20200919, Copyright 2000-2020 Kitware, Inc. and Contributors
Found GNU toolchain
C compiler on this system is: gcc
C++ compiler on this system is: g++ -std=gnu++17
Makefile processor on this system is: make
g++ has setenv
g++ has unsetenv
g++ does not have environ in stdlib.h
g++ has stl wstring
g++ has <ext/stdio_filebuf.h>
---------------------------------------------
g++ -std=gnu++17 -DCMAKE_BOOTSTRAP -DCMake_HAVE_CXX_MAKE_UNIQUE=1 -c $HOME/Apps/CMake-master/Source/cmAddCustomCommandCommand.cxx -o cmAddCustomCommandCommand.o
This is part of the error in the log file...
In file included from /usr/include/c++/5/unordered_map:35:0,
from cmake_bootstrap_11920_test.cxx:4:
/usr/include/c++/5/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
#error This file requires compiler and library support \
^
cmake_bootstrap_11920_test.cxx:7:2: error: #error "Compiler is not in a mode aware of C++11."
#error "Compiler is not in a mode aware of C++11."
^
cmake_bootstrap_11920_test.cxx:70:16: warning: non-static data member initializers only available with -std=c++11 or -std=gnu++11
int Member = 1;
Looking around on the web, I noticed that C++11 is only available after gcc version 4.6.
I checked my version, and it seems to be above.
g++ --version
g++ (Ubuntu 5.4.0-6ubuntu1~16.04.12) 5.4.0 20160609
I understand the -std=c++11 flag is used to enable the C++11 features in g++, but I don't seem to know what I am doing in this case.
I tried editing the CompileFlags.cmake file, but no change occurs.
I came upon this page which points to the cmake source I am using.
It says...
bootstrap: Require compiler mode aware of C++11
Some compilers have enough features enabled in their default modes to
pass our simple C++11 unique_ptr check but do not enable enough to build
CMake. Poison this case so that we choose one of the explicit `-std=`
options for such compilers.
Not sure what that means exactly.
How exactly do I change the g++ mode, to C++11, so that on running the bootstrap command, C++11 is used?
Or, in other words, how do I change std to point to C++11 (-std=c++11)?
First of all, you have g++ version 5.4.0 in your host PC installed, which is good, cause it means this is also supports the C++11, which you want to use.
To set it up, you could define it in your CMakeList.txt file:
set (CMAKE_CXX_STANDARD 11)
that should do the trick.
Please also check the documentation:
https://cmake.org/cmake/help/v3.1/variable/CMAKE_CXX_STANDARD.html
Usually, I would suggest to use the latest standard that you compiler is supporting (https://gcc.gnu.org/projects/cxx-status.html), cause you'll get also the latest features introduced in that standard. Exception for this rather in case you are working with legacy codes.

How to configure clang to use arm-none-eabi linker

I am trying to configure the last version of clang (6.0) to use the arm-none-eabi linker instead of the ld.lld but clang is always ignoring everything and keep asking for the ld.lld one. I am trying to build for cortex-m3 (lpx1769 board). How do I force clang to use the linker I want.
-fuse-ld=ld is also not working, so does clang no longer allow the use of any other linker?
So the answer was to use the flag:
-fuse-ld=path/to/linker-to-be-used
Remember that if you passing this flag to clang it will cause a warning that clang will not use this flag (only the linker stage will do). Thus if you compiling with -Werror, the warning will be turned into an error.
Moreover, because you are cross-compiling probably you will need to let the linker know where to find the target-specific libraries needed using the -L option. See this for more info:
https://clang.llvm.org/docs/CrossCompilation.html

cc1: error: command line option ‘-std=c++11’ is valid for C++/ObjC++ but not for C [-Werror]

I need the -std=c++11 flag for c++ modules when compile nginx. If I configure nginx with --with-cc-opt="-std=c++11" and then make. It gives me the error described in the title. How can I get it compile without modifing nginx source code or the compiler(for now it's gcc 4.8) version?
According to the documentation: "--with-cc-opt=parameters — sets additional parameters that will be added to the CFLAGS variable."
CFLAGS enables the addition of switches for the C compiler, while CXXFLAGS is meant to be used when invoking a C++ compiler.

What does gcc option -pthread mean?

I having a hell of a time tracking down documentation for all of the gcc options. I'm on an ubuntu machine so not even sure if this is relevant to me.
Comes from this make rule:
my-server: my-server.c
$(CC) -Wall -pthread my-server.c -o my-server
I've found this option summary:
https://gcc.gnu.org/onlinedocs/gcc-4.8.0/gcc/Option-Summary.html
From man gcc
-pthread
Add support for multithreading using the POSIX threads library. This option sets flags for both the preprocessor and linker. It does not affect the thread safety of object code produced by the compiler or that of libraries supplied with it. These are HP-UX specific flags.
Note that it differs from -lpthread. The -lpthread option doesn't set the preprocessor flags. For instance, the macros _REENTRANT and __USE_REENTRANT, etc.
In the documentation for GCC (6.2.0), it is treated as a platform-specific option. For RS6000 and PowerPC, it says:
-pthread.
Adds support for multithreading with the pthreads library. This option sets flags for both the preprocessor and linker.
For Solaris 2, it says:
-pthreads.
Add support for multithreading using the POSIX threads library. This option sets flags for both the preprocessor and linker. This option does not affect the thread safety of object code produced by the compiler or that of libraries supplied with it.
-pthread.
This is a synonym for -pthreads.
The common 'thread' (sorry — couldn't resist) is that it ensures that the code is compiled and linked with options that ensure that the POSIX threads library is used. The same will be true on other platforms where the option works (Linux, macOS Sierra, Mac OS X before it, …) it will link with the right library and enable any relevant preprocessor options.
You could compare the output of:
gcc -v -pthread -o x1 pthread-prog.c
gcc -v. -o x2 pthread-prog.c
to see what differences the -pthread option makes. On macOS Sierra, it adds -D_REENTRANT to the cc1 phase, and -pthread to the 'COLLECT_GCC_OPTIONS' setting.

"undefined reference" errors when trying to use address sanitizer with GCC

I'm trying to build my project with
g++ -O0 -g -fsanitize=address -fno-omit-frame-pointer
but get lots of errors like:
/home/user/libs/opencv/include/opencv2/core/mat.hpp:715: undefined reference to `__asan_report_load8'
How to compile project with AddressSanitize support?
My gcc version is 4.8.4.
You need to add -fsanitize=address to compiler flags (both CFLAGS and CXXFLAGS) and linker flags (LDFLAGS). You've probably added it to your compiler flags only.
Note that using explicit -lasan option has been widely discouraged by ASan developers (e.g. here) as it misses some other important linker flags. The only recommended way to link is to use -fsanitize=address.
As a side note, for more aggressive verification flags check Asan FAQ (look for "more aggressive diagnostics").
Make sure you have libasan installed. For example, in Fedora:
dnf install libasan libasan-static
You need to add the switch -lasan -fsanitize=address to your both your compile and link command line to link the correct library.
Note: the original answer -lasan is outdated and should not be used, as per comments

Resources