> > Have you seen that? > > https://stackoverflow.com/questions/19118854/unable-to-cross-compile-to-sparc-using-clang > I’m not sure sparc backend is well supported by clang/llvm. Try with > riscv.
Yes I saw. It is old post, I have clang 11 and it is detecting sparc as a target so I thought clang supports sparc I am trying with riscv, clang riscv files are missing so I need to fix. I got same issue with UBSan initially and fixed it by pasting UBSan files in correct location(clang puts them in wrong location) I am documenting everything here https://github.com/suyashsingh234/rtems-notes/blob/master/README.md On Mon, May 4, 2020 at 9:41 PM suyash singh <suyashsingh...@gmail.com> wrote: > with sparc-unknown-rtems5 > > clang version 11.0.0 (https://github.com/llvm/llvm-project.git > 05606329e2353e37492bcf567ab4a4b27bceb65c) > Target: sparc-unknown-rtems5 > Thread model: posix > InstalledDir: /home/suyash/Desktop/clanganalyzer/llvm-project/build2/bin > "/home/suyash/Desktop/clanganalyzer/llvm-project/build2/bin/clang-11" > -cc1 -triple sparc-unknown-rtems5 -emit-obj -mrelax-all -disable-free > -main-file-name test1.c -mrelocation-model static -mthread-model posix > -mframe-pointer=all -fmath-errno -fno-rounding-math -mconstructor-aliases > -mfloat-abi hard -dwarf-column-info -fno-split-dwarf-inlining > -debugger-tuning=gdb -v -resource-dir > /home/suyash/Desktop/clanganalyzer/llvm-project/build2/lib/clang/11.0.0 > -fdebug-compilation-dir /home/suyash/Desktop/clangtest -ferror-limit 19 > -fmessage-length 0 > -fsanitize=alignment,array-bounds,bool,builtin,enum,float-cast-overflow,integer-divide-by-zero,nonnull-attribute,null,pointer-overflow,return,returns-nonnull-attribute,shift-base,shift-exponent,signed-integer-overflow,unreachable,vla-bound > -fsanitize-recover=alignment,array-bounds,bool,builtin,enum,float-cast-overflow,integer-divide-by-zero,nonnull-attribute,null,pointer-overflow,returns-nonnull-attribute,shift-base,shift-exponent,signed-integer-overflow,vla-bound > -fgnuc-version=4.2.1 -fobjc-runtime=gcc -fdiagnostics-show-option > -fcolor-diagnostics -faddrsig -o /tmp/test1-ffe267.o -x c test1.c > clang -cc1 version 11.0.0 based upon LLVM 11.0.0git default target > x86_64-unknown-linux-gnu > #include "..." search starts here: > #include <...> search starts here: > /usr/local/include > > > /home/suyash/Desktop/clanganalyzer/llvm-project/build2/lib/clang/11.0.0/include > End of search list. > "/usr/bin/gcc" -fuse-ld=lld -fsanitize=undefined -v -o a.out > /tmp/test1-ffe267.o > Using built-in specs. > COLLECT_GCC=/usr/bin/gcc > COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper > OFFLOAD_TARGET_NAMES=nvptx-none > OFFLOAD_TARGET_DEFAULT=1 > Target: x86_64-linux-gnu > Configured with: ../src/configure -v --with-pkgversion='Ubuntu > 7.5.0-3ubuntu1~18.04' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs > --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr > --with-gcc-major-version-only --program-suffix=-7 > --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id > --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix > --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu > --enable-libstdcxx-debug --enable-libstdcxx-time=yes > --with-default-libstdcxx-abi=new --enable-gnu-unique-object > --disable-vtable-verify --enable-libmpx --enable-plugin > --enable-default-pie --with-system-zlib --with-target-system-zlib > --enable-objc-gc=auto --enable-multiarch --disable-werror > --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 > --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none > --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu > --host=x86_64-linux-gnu --target=x86_64-linux-gnu > Thread model: posix > gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04) > > COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/ > > LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/7/../../../:/lib/:/usr/lib/ > COLLECT_GCC_OPTIONS='-fuse-ld=lld' '-fsanitize=undefined' '-v' '-o' > 'a.out' '-mtune=generic' '-march=x86-64' > /usr/lib/gcc/x86_64-linux-gnu/7/collect2 -plugin > /usr/lib/gcc/x86_64-linux-gnu/7/liblto_plugin.so > -plugin-opt=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper > -plugin-opt=-fresolution=/tmp/ccJfTl2s.res -plugin-opt=-pass-through=-lgcc > -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc > -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s > --build-id --eh-frame-hdr -m elf_x86_64 --hash-style=gnu --as-needed > -dynamic-linker /lib64/ld-linux-x86-64.so.2 -pie -z now -fuse-ld=lld -z > relro -o a.out > /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/Scrt1.o > /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/crti.o > /usr/lib/gcc/x86_64-linux-gnu/7/crtbeginS.o > -L/usr/lib/gcc/x86_64-linux-gnu/7 > -L/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu > -L/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib -L/lib/x86_64-linux-gnu > -L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib > -L/usr/lib/gcc/x86_64-linux-gnu/7/../../.. /tmp/test1-ffe267.o --push-state > --no-as-needed -lubsan --pop-state -lgcc --push-state --as-needed -lgcc_s > --pop-state -lc -lgcc --push-state --as-needed -lgcc_s --pop-state > /usr/lib/gcc/x86_64-linux-gnu/7/crtendS.o > /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/crtn.o > ld.lld: error: /tmp/test1-ffe267.o is incompatible with elf64-x86-64 > collect2: error: ld returned 1 exit status > clang-11: error: linker (via gcc) command failed with exit code 1 (use -v > to see invocation) > > On Mon, May 4, 2020 at 9:40 PM suyash singh <suyashsingh...@gmail.com> > wrote: > >> Also can you add -v and send the output? >> >> >> clang version 11.0.0 (https://github.com/llvm/llvm-project.git >> 05606329e2353e37492bcf567ab4a4b27bceb65c) >> Target: sparc >> Thread model: posix >> InstalledDir: /home/suyash/Desktop/clanganalyzer/llvm-project/build2/bin >> "/home/suyash/Desktop/clanganalyzer/llvm-project/build2/bin/clang-11" >> -cc1 -triple sparc -emit-obj -mrelax-all -disable-free -main-file-name >> test1.c -mrelocation-model static -mthread-model posix -mframe-pointer=all >> -fmath-errno -fno-rounding-math -mconstructor-aliases -mfloat-abi hard >> -dwarf-column-info -fno-split-dwarf-inlining -debugger-tuning=gdb -v >> -resource-dir >> /home/suyash/Desktop/clanganalyzer/llvm-project/build2/lib/clang/11.0.0 >> -fdebug-compilation-dir /home/suyash/Desktop/clangtest -ferror-limit 19 >> -fmessage-length 0 >> -fsanitize=alignment,array-bounds,bool,builtin,enum,float-cast-overflow,integer-divide-by-zero,nonnull-attribute,null,pointer-overflow,return,returns-nonnull-attribute,shift-base,shift-exponent,signed-integer-overflow,unreachable,vla-bound >> -fsanitize-recover=alignment,array-bounds,bool,builtin,enum,float-cast-overflow,integer-divide-by-zero,nonnull-attribute,null,pointer-overflow,returns-nonnull-attribute,shift-base,shift-exponent,signed-integer-overflow,vla-bound >> -fgnuc-version=4.2.1 -fobjc-runtime=gcc -fdiagnostics-show-option >> -fcolor-diagnostics -faddrsig -o /tmp/test1-6da71f.o -x c test1.c >> clang -cc1 version 11.0.0 based upon LLVM 11.0.0git default target >> x86_64-unknown-linux-gnu >> #include "..." search starts here: >> #include <...> search starts here: >> /usr/local/include >> >> >> /home/suyash/Desktop/clanganalyzer/llvm-project/build2/lib/clang/11.0.0/include >> /usr/include >> End of search list. >> "/usr/bin/gcc" -fuse-ld=lld -fsanitize=undefined -v -o a.out >> /tmp/test1-6da71f.o >> Using built-in specs. >> COLLECT_GCC=/usr/bin/gcc >> COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper >> OFFLOAD_TARGET_NAMES=nvptx-none >> OFFLOAD_TARGET_DEFAULT=1 >> Target: x86_64-linux-gnu >> Configured with: ../src/configure -v --with-pkgversion='Ubuntu >> 7.5.0-3ubuntu1~18.04' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs >> --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr >> --with-gcc-major-version-only --program-suffix=-7 >> --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id >> --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix >> --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu >> --enable-libstdcxx-debug --enable-libstdcxx-time=yes >> --with-default-libstdcxx-abi=new --enable-gnu-unique-object >> --disable-vtable-verify --enable-libmpx --enable-plugin >> --enable-default-pie --with-system-zlib --with-target-system-zlib >> --enable-objc-gc=auto --enable-multiarch --disable-werror >> --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 >> --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none >> --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu >> --host=x86_64-linux-gnu --target=x86_64-linux-gnu >> Thread model: posix >> gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04) >> >> COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/ >> >> LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/7/../../../:/lib/:/usr/lib/ >> COLLECT_GCC_OPTIONS='-fuse-ld=lld' '-fsanitize=undefined' '-v' '-o' >> 'a.out' '-mtune=generic' '-march=x86-64' >> /usr/lib/gcc/x86_64-linux-gnu/7/collect2 -plugin >> /usr/lib/gcc/x86_64-linux-gnu/7/liblto_plugin.so >> -plugin-opt=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper >> -plugin-opt=-fresolution=/tmp/ccrvaAg0.res -plugin-opt=-pass-through=-lgcc >> -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc >> -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s >> --build-id --eh-frame-hdr -m elf_x86_64 --hash-style=gnu --as-needed >> -dynamic-linker /lib64/ld-linux-x86-64.so.2 -pie -z now -fuse-ld=lld -z >> relro -o a.out >> /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/Scrt1.o >> /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/crti.o >> /usr/lib/gcc/x86_64-linux-gnu/7/crtbeginS.o >> -L/usr/lib/gcc/x86_64-linux-gnu/7 >> -L/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu >> -L/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib -L/lib/x86_64-linux-gnu >> -L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib >> -L/usr/lib/gcc/x86_64-linux-gnu/7/../../.. /tmp/test1-6da71f.o --push-state >> --no-as-needed -lubsan --pop-state -lgcc --push-state --as-needed -lgcc_s >> --pop-state -lc -lgcc --push-state --as-needed -lgcc_s --pop-state >> /usr/lib/gcc/x86_64-linux-gnu/7/crtendS.o >> /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/crtn.o >> ld.lld: error: /tmp/test1-6da71f.o is incompatible with elf64-x86-64 >> collect2: error: ld returned 1 exit status >> clang-11: error: linker (via gcc) command failed with exit code 1 (use -v >> to see invocation) >> >> On Mon, May 4, 2020 at 6:26 PM Hesham Almatary < >> hesham.almat...@cl.cam.ac.uk> wrote: >> >>> Have you seen that? >>> >>> https://stackoverflow.com/questions/19118854/unable-to-cross-compile-to-sparc-using-clang >>> >>> I’m not sure sparc backend is well supported by clang/llvm. Try with >>> riscv. >>> >>> On Mon, 4 May 2020 at 13:34, Hesham Almatary < >>> hesham.almat...@cl.cam.ac.uk> wrote: >>> >>>> >>>> >>>> On Mon, 4 May 2020 at 13:19, Joel Sherrill <j...@rtems.org> wrote: >>>> >>>>> >>>>> >>>>> On Mon, May 4, 2020, 7:16 AM suyash singh <suyashsingh...@gmail.com> >>>>> wrote: >>>>> >>>>>> I am trying to cross compile with clang and run Undefined Behavior >>>>>> Sanitizer for .c file >>>>>> >>>>>> *Command I am running* >>>>>> >>>>>> clang -target sparc -integrated-as -fuse-ld=lld -fsanitize=undefined >>>>>> test1.c >>>>>> >>>>>> clang is the cross compiler >>>>>> >>>>>> sparc is the target architecture. >>>>>> >>>>>> -integrated-as to use the llvm assembler >>>>>> >>>>>> -fuse-ld=lld to use lld linker >>>>>> >>>>>> -fsanitize=undefined to run UBSan >>>>>> >>>>>> *Error* >>>>>> >>>>>> ld.lld: error: /tmp/test1-43c7c0.o is incompatible with elf64-x86-64 >>>>>> >>>>>> collect2: error: ld returned 1 exit status >>>>>> >>>>>> clang-11: error: linker (via gcc) command failed with exit code 1 >>>>>> (use -v to see invocation) >>>>>> >>>>>> *My system* >>>>>> >>>>>> Ubuntu 18.04 >>>>>> >>>>>> x86_64 >>>>>> >>>>>> command executed on ubuntu terminal >>>>>> >>>>>> without -target sparc on a file.c which does not contain sparc >>>>>> assembly the clang works fine >>>>>> >>>>> >>>>> This is the same problem you had with as. You need to properly specify >>>>> the target and have the target as and ld in your PATH. >>>>> >>>> >>>> Also can you add -v and send the output? >>>> >>>>> >>>>> --joel >>>>> >>>>>> _______________________________________________ >>>>>> devel mailing list >>>>>> devel@rtems.org >>>>>> http://lists.rtems.org/mailman/listinfo/devel >>>>> >>>>> _______________________________________________ >>>>> devel mailing list >>>>> devel@rtems.org >>>>> http://lists.rtems.org/mailman/listinfo/devel >>>> >>>> _______________________________________________ >>> devel mailing list >>> devel@rtems.org >>> http://lists.rtems.org/mailman/listinfo/devel >> >>
_______________________________________________ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel