[LLVMdev] [LLVM 3.5]: relocation truncated to fit: R_X86_64_32

zosrothko zosrothko at orange.fr
Mon Mar 17 23:59:06 PDT 2014


Hello LLVM and clang listeners

I am a newcomer to the LLVM project, building the LLVM and clang project on
a Cygwin/win7/x86_64 platform. After fixing the include issue of some C
functions not available thru the c++1 standard on cygwin (see this
thread:http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60498), I finally succeed
in building LLVM and clang from the svn 3.5 repository.

But, the includes issues were continuing thru the predefined constants which
are differents between gcc and clang

$ clang hello.c -o hello
In file included from hello.c:1:
In file included from /usr/include/stdio.h:35:
In file included from /usr/include/sys/cdefs.h:43:
/usr/include/machine/_default_types.h:28:9: error: unknown type name
'__UINT8_TYPE__'
typedef __UINT8_TYPE__ __uint8_t;
         ^
/usr/include/machine/_default_types.h:38:9: error: unknown type name
'__UINT16_TYPE__'
typedef __UINT16_TYPE__ __uint16_t;
         ^
/usr/include/machine/_default_types.h:56:9: error: unknown type name
'__UINT32_TYPE__'
typedef __UINT32_TYPE__ __uint32_t;
         ^
/usr/include/machine/_default_types.h:78:9: error: unknown type name
'__UINT64_TYPE__'
typedef __UINT64_TYPE__ __uint64_t;
         ^
/usr/include/machine/_default_types.h:169:9: error: unknown type name
'__UINTPTR_TYPE__'
typedef __UINTPTR_TYPE__ __uintptr_t;
         ^
5 errors generated.

In effect, INT and UINT types are defined by gcc while only INT types are
defined by clang

$ gcc  -dM -E - < /dev/null | sort | grep UINT8
#define __UINT8_C(c) c
#define __UINT8_MAX__ 255
#define __UINT8_TYPE__ unsigned char

$ gcc  -dM -E - < /dev/null | sort | grep INT8
#define __INT8_C(c) c
#define __INT8_MAX__ 127
#define __INT8_TYPE__ signed char
#define __UINT8_C(c) c
#define __UINT8_MAX__ 255
#define __UINT8_TYPE__ unsigned char

$ clang  -dM -E - < /dev/null | sort | grep UINT8


$ clang  -dM -E - < /dev/null | sort | grep INT8
#define __INT8_TYPE__ char



Thus, I fixed the cygwin includes for getting a clean compile. But then, the
linking phase gets trouble with

$ clang hello.c -o hello
/tmp/hello-5de8e5.o:(.text+0x15): relocation truncated to fit: R_X86_64_32
against `.rdata'
/tmp/hello-5de8e5.o:(.eh_frame+0x20): relocation truncated to fit:
R_X86_64_32 against `.text'
collect2: error: ld returned 1 exit status
clang: error: linker (via gcc) command failed with exit code 1 (use -v to
see invocation)


$ clang -v hello.c -o hello
clang version 3.5.0 (trunk 204001) (204002)
Target: x86_64-unknown-cygwin
Thread model: posix
  "/usr/local/bin/clang" -cc1 -triple x86_64-unknown-cygwin -emit-obj
-mrelax-all -disable-free -main-file-name hello.c -mrelocation-model static
-mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases
-munwind-tables -target-cpu x86-64 -target-linker-version 2.23.52.20130604
-v -resource-dir /usr/local/bin/../lib/clang/3.5.0 -fdebug-compilation-dir
/cygdrive/z/dev/llvm/x64/buggcc -ferror-limit 19 -fmessage-length 115
-mstackrealign -fno-use-cxa-atexit -fobjc-runtime=gcc
-fdiagnostics-show-option -vectorize-slp -o /tmp/hello-a4f6e6.o -x c hello.c
clang -cc1 version 3.5.0 based upon LLVM 3.5.0svn default target
x86_64-unknown-cygwin
#include "..." search starts here:
#include <...> search starts here:
  /usr/local/include
  /usr/local/bin/../lib/clang/3.5.0/include
  /usr/include/w32api
  /usr/include
End of search list.
  "/usr/bin/gcc" -v -m64 -o hello /tmp/hello-a4f6e6.o
Using built-in specs.
COLLECT_GCC=/usr/bin/gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-cygwin/4.8.2/lto-wrapper.exe
Target: x86_64-pc-cygwin
Configured with:
/cygdrive/i/szsz/tmpp/cygwin64/gcc/gcc-4.8.2-3/src/gcc-4.8.2/configure
--srcdir=/cygdrive/i/szsz/tmpp/cygwin64/gcc/gcc-4.8.2-3/src/gcc-4.8.2
--prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin
--libexecdir=/usr/libexec --datadir=/usr/share --localstatedir=/var
--sysconfdir=/etc --libdir=/usr/lib --datarootdir=/usr/share
--docdir=/usr/share/doc/gcc --htmldir=/usr/share/doc/gcc/html -C
--build=x86_64-pc-cygwin --host=x86_64-pc-cygwin --target=x86_64-pc-cygwin
--without-libiconv-prefix --without-libintl-prefix --enable-shared
--enable-shared-libgcc --enable-static
--enable-version-specific-runtime-libs --enable-bootstrap
--disable-__cxa_atexit --with-dwarf2 --with-tune=generic
--enable-languages=ada,c,c++,fortran,lto,objc,obj-c++ --enable-graphite
--enable-threads=posix --enable-libatomic --enable-libgomp --disable-libitm
--enable-libquadmath --enable-libquadmath-support --enable-libssp
--enable-libada --enable-libgcj-sublibs --disable-java-awt --disable-symvers
--with-ecj-jar=/usr/share/java/ecj.jar --with-gnu-ld --with-gnu-as
--with-cloog-include=/usr/include/cloog-isl --without-libiconv-prefix
--without-libintl-prefix --with-system-zlib --libexecdir=/usr/lib
Thread model: posix
gcc version 4.8.2 (GCC)
COMPILER_PATH=/usr/lib/gcc/x86_64-pc-cygwin/4.8.2/:/usr/lib/gcc/x86_64-pc-cygwin/4.8.2/:/usr/lib/gcc/x86_64-pc-cygwin/:/usr/lib/gcc/x86_64-pc-cygwin/4.8.2/:/usr/lib/gcc/x86_64-pc-cygwin/:/usr/lib/gcc/x86_64-pc-cygwin/4.8.2/../../../../x86_64-pc-cygwin/bin/
LIBRARY_PATH=/usr/lib/gcc/x86_64-pc-cygwin/4.8.2/:/usr/lib/gcc/x86_64-pc-cygwin/4.8.2/../../../../x86_64-pc-cygwin/lib/../lib/:/usr/lib/gcc/x86_64-pc-cygwin/4.8.2/../../../../lib/:/lib/../lib/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-pc-cygwin/4.8.2/../../../../x86_64-pc-cygwin/lib/:/usr/lib/gcc/x86_64-pc-cygwin/4.8.2/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-m64' '-o' 'hello.exe' '-mtune=generic'
'-march=x86-64'
  /usr/lib/gcc/x86_64-pc-cygwin/4.8.2/collect2.exe -m i386pep --wrap _Znwm
--wrap _Znam --wrap _ZdlPv --wrap _ZdaPv --wrap _ZnwmRKSt9nothrow_t --wrap
_ZnamRKSt9nothrow_t --wrap _ZdlPvRKSt9nothrow_t --wrap _ZdaPvRKSt9nothrow_t
-Bdynamic --dll-search-prefix=cyg --tsaware -o hello.exe
/usr/lib/gcc/x86_64-pc-cygwin/4.8.2/../../../../lib/crt0.o
/usr/lib/gcc/x86_64-pc-cygwin/4.8.2/crtbegin.o
-L/usr/lib/gcc/x86_64-pc-cygwin/4.8.2
-L/usr/lib/gcc/x86_64-pc-cygwin/4.8.2/../../../../x86_64-pc-cygwin/lib/../lib
-L/usr/lib/gcc/x86_64-pc-cygwin/4.8.2/../../../../lib -L/lib/../lib
-L/usr/lib/../lib
-L/usr/lib/gcc/x86_64-pc-cygwin/4.8.2/../../../../x86_64-pc-cygwin/lib
-L/usr/lib/gcc/x86_64-pc-cygwin/4.8.2/../../.. /tmp/hello-a4f6e6.o -lgcc_s
-lgcc -lcygwin -ladvapi32 -lshell32 -luser32 -lkernel32 -lgcc_s -lgcc
/usr/lib/gcc/x86_64-pc-cygwin/4.8.2/crtend.o
/tmp/hello-a4f6e6.o:(.text+0x15): relocation truncated to fit: R_X86_64_32
against `.rdata'
/tmp/hello-a4f6e6.o:(.eh_frame+0x20): relocation truncated to fit:
R_X86_64_32 against `.text'
collect2: error: ld returned 1 exit status
clang: error: linker (via gcc) command failed with exit code 1 (use -v to
see invocation)

So, how can I continue walking on the clang side?

TIA

zos






--
View this message in context: 
http://llvm.1065342.n5.nabble.com/Walk-on-the-clang-side-tp66860.html
Sent from the LLVM - Dev mailing list archive at Nabble.com.
_______________________________________________
LLVM Developers mailing list
LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev




More information about the llvm-dev mailing list