Skip to Content.
Sympa Menu

svadev - [svadev] Antwort: Re: Re: clang: error: linker (via gcc) command failed with exit code 1 (use -v to see invocation)

svadev AT lists.siebelschool.illinois.edu

Subject: Svadev mailing list

List archive

[svadev] Antwort: Re: Re: clang: error: linker (via gcc) command failed with exit code 1 (use -v to see invocation)


Chronological Thread 
  • From: Stefan.Scheruebl AT continental-corporation.com
  • To: jonas.wagner AT epfl.ch
  • Cc: svadev AT cs.uiuc.edu
  • Subject: [svadev] Antwort: Re: Re: clang: error: linker (via gcc) command failed with exit code 1 (use -v to see invocation)
  • Date: Tue, 25 Nov 2014 14:01:35 +0100
  • List-archive: <http://lists.cs.uiuc.edu/pipermail/svadev/>
  • List-id: <svadev.cs.uiuc.edu>

Hi Jonas!

Unfortunately I have to proof my the concept for a windows environment. Nevertheless I made the tests also for LINUX which causes no problems...hmmm


Success with:
clang -c -integrated-as -fmemsafety -v -g -I/home/uid04950/WORK/LLVM_INSTALL/include testcode.c
clang -v -g -o testcode.exe testcode.o -L/home/uid04950/WORK/LLVM_INSTALL/lib -lsc_dbg_rt -lsc_bb_rt -lpoolalloc_bitmap -lgdtoa -lstdc++ -lgcc_s -lc

Fail with:
clang -integrated-as -fmemsafety -v -g -I/home/uid04950/WORK/LLVM_INSTALL/include -o testcode.exe testcode.c -L/home/uid04950/WORK/LLVM_INSTALL/lib -lsc_dbg_rt -lsc_bb_rt -lpoolalloc_bitmap -lgdtoa -lstdc++ -lgcc_s -lc



The issue that -fmemsafety is assigned to the linker seems to be an error only on the cygwin environment but at the moment I've not the knowledge to solve that issue.
Would the Safecode stuff work this would not be a problem but unfortunately if I execute the compiled file I get a crash - the prompt does not return...
But it is the same if I compile and execute a normal HelloWord code - without buggy code - hmmm

Here is my log - would be great if you could give me some hints!

uid04950@RBL8XP0G ~/WORK/LLVM_INSTALL
$ cat testcode.c
#include "stdio.h"
#include "stdio.h"
#include "stdlib.h"

int
foo (char * bar) {
  for (unsigned index = 0; index < 10; ++index)
    bar[index] = 'a';
  return 0;
}

int
main (int argc, char ** argv)
{
#if 0
   printf("Hallo Welt");
#else
  char * array[100];
  int max = atoi (argv[1]);

   printf("Hallo Welt");

  for (int index = max; index >= 0; --index) {
    array[index] = malloc (index+1);
  }

  for (int index = max; index >= 0; --index) {
    foo (array[index]);
  }

  exit (0);
#endif
}

uid04950@RBL8XP0G ~/WORK/LLVM_INSTALL
$ clang -c -integrated-as -fmemsafety -v -g -I/home/uid04950/WORK/LLVM_INSTALL/include testcode.c
clang version 3.2 (: http://llvm.org/svn/llvm-project/safecode/branches/release_32/tools/clang) (llvm/branches/release_32 ^/llvm/branches/release_32 212254)
Target: i386-pc-cygwin
Thread model: posix
 "/home/uid04950/WORK/LLVM_INSTALL/bin/clang" -cc1 -triple i386-pc-cygwin -emit-obj -mrelax-all -disable-free -main-file-name testcode.c -mrelocation-model static -mdisable-fp-elim -fmath-errno -mcons
tructor-aliases -target-cpu pentium4 -target-linker-version 2.24.51.20140703 -momit-leaf-frame-pointer -v -g -coverage-file /home/uid04950/WORK/LLVM_INSTALL/testcode.o -resource-dir /home/uid04950/WOR
K/LLVM_INSTALL/bin/../lib/clang/3.2 -I /home/uid04950/WORK/LLVM_INSTALL/include -fmodule-cache-path /var/tmp/clang-module-cache -fdebug-compilation-dir /home/uid04950/WORK/LLVM_INSTALL -ferror-limit 1
9 -fmessage-length 200 -fmemsafety -mstackrealign -fno-use-cxa-atexit -fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-diagnostics -o testcode.o -x c testcode.c
clang -cc1 version 3.2 based upon LLVM 3.2svn default target i386-pc-cygwin
ignoring nonexistent directory "/usr/local/include"
#include "..." search starts here:
#include <...> search starts here:
 /home/uid04950/WORK/LLVM_INSTALL/include
 /home/uid04950/WORK/LLVM_INSTALL/bin/../lib/clang/3.2/include
 /usr/include/w32api
 /usr/include
End of search list.

uid04950@RBL8XP0G ~/WORK/LLVM_INSTALL
$ clang -v -g -o testcode.exe testcode.o -L/home/uid04950/WORK/LLVM_INSTALL/lib -lsc_dbg_rt -lsc_bb_rt -lpoolalloc_bitmap -lgdtoa -lstdc++ -lgcc_s -lc
clang version 3.2 (: http://llvm.org/svn/llvm-project/safecode/branches/release_32/tools/clang) (llvm/branches/release_32 ^/llvm/branches/release_32 212254)
Target: i386-pc-cygwin
Thread model: posix
 "/usr/bin/gcc" -v -g -L/home/uid04950/WORK/LLVM_INSTALL/lib -m32 -o testcode.exe testcode.o -lsc_dbg_rt -lsc_bb_rt -lpoolalloc_bitmap -lgdtoa -lstdc++ -lgcc_s -lc
Es werden eingebaute Spezifikationen verwendet.
COLLECT_GCC=/usr/bin/gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-pc-cygwin/4.8.3/lto-wrapper.exe
Ziel: i686-pc-cygwin
Konfiguriert mit: /cygdrive/i/szsz/tmpp/gcc4/gcc-4.8.3-2.i686/src/gcc-4.8.3/configure --srcdir=/cygdrive/i/szsz/tmpp/gcc4/gcc-4.8.3-2.i686/src/gcc-4.8.3 --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/shar
e/doc/gcc/html -C --build=i686-pc-cygwin --host=i686-pc-cygwin --target=i686-pc-cygwin --without-libiconv-prefix --without-libintl-prefix --enable-shared --enable-shared-libgcc --enable-static --enabl
e-version-specific-runtime-libs --enable-bootstrap --disable-__cxa_atexit --with-dwarf2 --with-arch=i686 --with-tune=generic --disable-sjlj-exceptions --enable-languages=ada,c,c++,fortran,java,lto,obj
c,obj-c++ --enable-graphite --enable-threads=posix --enable-libatomic --enable-libgomp --disable-libitm --enable-libquadmath --enable-libquadmath-support --enable-libssp --enable-libada --enable-libja
va --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-Modell: posix
gcc-Version 4.8.3 (GCC)
COMPILER_PATH=/usr/lib/gcc/i686-pc-cygwin/4.8.3/:/usr/lib/gcc/i686-pc-cygwin/4.8.3/:/usr/lib/gcc/i686-pc-cygwin/:/usr/lib/gcc/i686-pc-cygwin/4.8.3/:/usr/lib/gcc/i686-pc-cygwin/:/usr/lib/gcc/i686-pc-cy
gwin/4.8.3/../../../../i686-pc-cygwin/bin/
LIBRARY_PATH=/usr/lib/gcc/i686-pc-cygwin/4.8.3/:/usr/lib/gcc/i686-pc-cygwin/4.8.3/../../../../i686-pc-cygwin/lib/:/usr/lib/gcc/i686-pc-cygwin/4.8.3/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-g' '-L/home/uid04950/WORK/LLVM_INSTALL/lib' '-m32' '-o' 'testcode.exe' '-mtune=generic' '-march=i686'
 /usr/lib/gcc/i686-pc-cygwin/4.8.3/collect2.exe --wrap _Znwj --wrap _Znaj --wrap _ZdlPv --wrap _ZdaPv --wrap _ZnwjRKSt9nothrow_t --wrap _ZnajRKSt9nothrow_t --wrap _ZdlPvRKSt9nothrow_t --wrap _ZdaPvRKS
t9nothrow_t -Bdynamic --dll-search-prefix=cyg --large-address-aware --tsaware -o testcode.exe /usr/lib/gcc/i686-pc-cygwin/4.8.3/../../../crt0.o /usr/lib/gcc/i686-pc-cygwin/4.8.3/crtbegin.o -L/home/uid
04950/WORK/LLVM_INSTALL/lib -L/usr/lib/gcc/i686-pc-cygwin/4.8.3 -L/usr/lib/gcc/i686-pc-cygwin/4.8.3/../../../../i686-pc-cygwin/lib -L/usr/lib/gcc/i686-pc-cygwin/4.8.3/../../.. testcode.o -lsc_dbg_rt -
lsc_bb_rt -lpoolalloc_bitmap -lgdtoa -lstdc++ -lgcc_s -lc -lgcc_s -lgcc -lcygwin -ladvapi32 -lshell32 -luser32 -lkernel32 -lgcc_s -lgcc /usr/lib/gcc/i686-pc-cygwin/4.8.3/../../../default-manifest.o /u
sr/lib/gcc/i686-pc-cygwin/4.8.3/crtend.o

uid04950@RBL8XP0G ~/WORK/LLVM_INSTALL
$ ./testcode.exe      => Here - no output, no return....







Log of fail:

clang -integrated-as -fmemsafety -v -g -I/home/uid04950/WORK/LLVM_INSTALL/include -o testcode.exe testcode.c -L/home/uid04950/WORK/LLVM_INSTALL/lib -lsc_dbg_rt -lsc_bb_rt -lpoolalloc_bitmap -lgdtoa -l
stdc++ -lgcc_s -lc
clang version 3.2 (: http://llvm.org/svn/llvm-project/safecode/branches/release_32/tools/clang) (llvm/branches/release_32 ^/llvm/branches/release_32 212254)
Target: i386-pc-cygwin
Thread model: posix
 "/home/uid04950/WORK/LLVM_INSTALL/bin/clang" -cc1 -triple i386-pc-cygwin -emit-obj -mrelax-all -disable-free -main-file-name testcode.c -mrelocation-model static -mdisable-fp-elim -fmath-errno -mcons
tructor-aliases -target-cpu pentium4 -target-linker-version 2.24.51.20140703 -momit-leaf-frame-pointer -v -g -resource-dir /home/uid04950/WORK/LLVM_INSTALL/bin/../lib/clang/3.2 -I /home/uid04950/WORK/
LLVM_INSTALL/include -fmodule-cache-path /var/tmp/clang-module-cache -fdebug-compilation-dir /home/uid04950/WORK/LLVM_INSTALL -ferror-limit 19 -fmessage-length 200 -fmemsafety -mstackrealign -fno-use-
cxa-atexit -fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-diagnostics -o /tmp/testcode-PUTGcw.o -x c testcode.c
clang -cc1 version 3.2 based upon LLVM 3.2svn default target i386-pc-cygwin
ignoring nonexistent directory "/usr/local/include"
#include "..." search starts here:
#include <...> search starts here:
 /home/uid04950/WORK/LLVM_INSTALL/include
 /home/uid04950/WORK/LLVM_INSTALL/bin/../lib/clang/3.2/include
 /usr/include/w32api
 /usr/include
End of search list.
 "/usr/bin/gcc" -fmemsafety -v -g -I /home/uid04950/WORK/LLVM_INSTALL/include -L/home/uid04950/WORK/LLVM_INSTALL/lib -m32 -o testcode.exe /tmp/testcode-PUTGcw.o -lsc_dbg_rt -lsc_bb_rt -lpoolalloc_bitm
ap -lgdtoa -lstdc++ -lgcc_s -lc
Es werden eingebaute Spezifikationen verwendet.
COLLECT_GCC=/usr/bin/gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-pc-cygwin/4.8.3/lto-wrapper.exe
gcc: Fehler: nicht erkannte Kommandozeilenoption »-fmemsafety«
Ziel: i686-pc-cygwin
Konfiguriert mit: /cygdrive/i/szsz/tmpp/gcc4/gcc-4.8.3-2.i686/src/gcc-4.8.3/configure --srcdir=/cygdrive/i/szsz/tmpp/gcc4/gcc-4.8.3-2.i686/src/gcc-4.8.3 --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/shar
e/doc/gcc/html -C --build=i686-pc-cygwin --host=i686-pc-cygwin --target=i686-pc-cygwin --without-libiconv-prefix --without-libintl-prefix --enable-shared --enable-shared-libgcc --enable-static --enabl
e-version-specific-runtime-libs --enable-bootstrap --disable-__cxa_atexit --with-dwarf2 --with-arch=i686 --with-tune=generic --disable-sjlj-exceptions --enable-languages=ada,c,c++,fortran,java,lto,obj
c,obj-c++ --enable-graphite --enable-threads=posix --enable-libatomic --enable-libgomp --disable-libitm --enable-libquadmath --enable-libquadmath-support --enable-libssp --enable-libada --enable-libja
va --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-Modell: posix
gcc-Version 4.8.3 (GCC)
clang: error: linker (via gcc) command failed with exit code 1 (use -v to see invocation)


Best,
Stefan






Von:        Jonas Wagner <jonas.wagner AT epfl.ch>
An:        Stefan.Scheruebl AT continental-corporation.com,
Kopie:        Jonas Wagner <jonas.wagner AT epfl.ch>, svadev AT cs.uiuc.edu
Datum:        21.11.2014 23:46
Betreff:        Re: Re: [svadev] clang: error: linker (via gcc) command failed with exit code 1 (use -v to see invocation)



Hi,

Great that it works now!

The errors that you see feel a bit mysterious to me... let me tell you what should happen:

- You invoke clang for linking, and pass the -fmemsafety option. e.g.:

        clang -fmemsafety foo.o bar.o -o foobar

  Usually, you can achieve this behavior if you set LDFLAGS=-fmemsafety prior to invoking ./configure or so.

- The clang driver sees the -fmemsafety option, and transforms it to a set of libraries and libpaths.
- Clang invokes the system linker without the -fmemsafety option, but with the object files and all the libraries required for memsafety.

Now I haven't tested this very recently... and never on Cygwin. Would it be a lot of trouble for you to develop under Linux? VMs are quite quick to set up these days :)

Cheers,
Jonas


On Wed, Nov 19, 2014 at 6:42 AM, <Stefan.Scheruebl AT continental-corporation.com> wrote:
Hi Jonas,

thanks for your response! Main thing first - I'm now able to compile without errors :-)


But I think I've still knowlege leaks regarding the Clang/LLVM design. So I try to explain what has happend in my fail case out of my view - correct me if I'm wrong...


1) Clang is the C-Frontend and works properly with the -fmemsaftey option (in my clang compilation)

2) The Clang compilation uses the native linker - in my case part of gcc - to link the native executeable which does not supply the -fmemsafety option support

3) LLVM supplies no native linker - till now - only a IR code linker

4) So the linker works correct if the -fmemsafety option is not used but in my case I forgot to add the safecode libraries to the linker call


Question:

1: How can I configure the clang compilation in a way that the linker is called without this -fmemsafety option automatically?

2: How can I configure the clang compilation in a way that the missing safecode libraries are automatically assigned to the linker command line when I call clang?


This command worked for me - how can I compile clang to use all the parameter as default?


$ CFLAGS="-g -fmemsafety -integrated-as" clang testcode.c -I/home/uid04950/WORK/LLVM_INSTALL/include -L/home/uid04950/WORK/LLVM_INSTALL/lib -lsc_dbg_rt -lsc_bb_rt -lgcc -lpoolalloc_bitmap -lstdc++ -lgdtoa -lgdtoa -lgcc_s -lc


Stefan





Von:        
Jonas Wagner <jonas.wagner AT epfl.ch>
An:        
Stefan.Scheruebl AT continental-corporation.com,
Kopie:        
svadev AT cs.uiuc.edu
Datum:        
18.11.2014 14:47
Betreff:        
Re: [svadev] clang: error: linker (via gcc) command failed with exit code 1 (use -v to see invocation)





Hi,

sorry for the late reply!

In the second case, the linker command likely fails because you didn't add the -fmemsafety option to the linker command line.

In the first case, it seems to fail because gcc does not recognize the -fmemsafety flag. I don't understand why clang would call GCC to link the program instead of doing it itself. Maybe this is the default behavior under cygwin? Have you checked whether the issue arises also when you run this under Linux?

Best,
Jonas





Archive powered by MHonArc 2.6.16.

Top of Page