LLVM/Clang on RISC-V Linux OS

114 views
Skip to first unread message

Billa Surendra

unread,
May 10, 2022, 8:14:09 AM5/10/22
to RISC-V SW Dev
Dear All,

I am struggling to install LLVM/Clang on my RISC-V Linux OS. Can anyone please help me to resolve the problem which I am facing?.

Here I am attaching the error message.

Thanks
Billa

error_message.txt

Khem Raj

unread,
May 10, 2022, 2:06:29 PM5/10/22
to Billa Surendra, RISC-V SW Dev
linker is segfaulting after printing bunch of unresolved symbols

collect2: fatal error: ld terminated with signal 11 [Segmentation fault]

So it could be that your system is running out of memory, or perhaps a
linker bug.
it seems you are trying to natively compile llvm on a rv64 machine,
how much RAM do you have on this machine ?
> --
> You received this message because you are subscribed to the Google Groups "RISC-V SW Dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sw-dev+un...@groups.riscv.org.
> To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/sw-dev/CAKBF_5q%3DJd%2BJQ4bjpyCPdfLSJpeo4TqVpY%2BBpG1Z-0ynhMqFvQ%40mail.gmail.com.

Jim Wilson

unread,
May 10, 2022, 3:37:47 PM5/10/22
to Billa Surendra, RISC-V SW Dev
On Tue, May 10, 2022 at 5:14 AM Billa Surendra <billa.i...@gmail.com> wrote:
I am struggling to install LLVM/Clang on my RISC-V Linux OS. Can anyone please help me to resolve the problem which I am facing?.
Here I am attaching the error message.

 This error
    /usr/lib/gcc/riscv64-unknown-linux-gnu/7.3.1/../../../../riscv64-unknown-linux-gnu/bin/ld: /usr/lib/libcurses.a(lib_cur_term.o): relocation R_RISCV_HI20 against `ospeed' can not be used when making a shared object; recompile with -fPIC
means that you need to build a libcurses.so.

There may also be other problems here like the out-of-memory issue Khem mentioned.  I know from my unmatched/Open Embedded work that we need about 12GB of virtual memory in order to build LLVM.  And reducing the parallelism helps so that you aren't doing multiple links at the same time.  You can just keep restarting the build after it crashes with less parallelism until it succeeds.  If you don't have enough memory, but have disk space, you can just add some large swap files.  It will be slow but should work.

Building LLVM stresses the whole system.  If you are still using old unpatched versions of stuff you might run into toolchain bugs that we have already fixed.  Looks like you still have gcc 7.3.1 which is very old.

Jim

Liviu Ionescu

unread,
May 10, 2022, 4:05:04 PM5/10/22
to RISC-V SW Dev, jim.wil...@gmail.com, RISC-V SW Dev, billa.i...@gmail.com

> need about 12GB of virtual memory in order to build LLVM.

I managed to build LLVM 13 on a Raspberry Pi 4 with only 4 GB of RAM, running RPi OS 32-bit.

Liviu

Jim Wilson

unread,
May 10, 2022, 4:21:28 PM5/10/22
to Liviu Ionescu, RISC-V SW Dev, billa.i...@gmail.com
On Tue, May 10, 2022 at 1:05 PM Liviu Ionescu <i...@livius.net> wrote:
> need about 12GB of virtual memory in order to build LLVM.

I managed to build LLVM 13 on a Raspberry Pi 4 with only 4 GB of RAM, running RPi OS 32-bit.

Maybe it depends on how LLVM is configured, or what optimization options are used for the build.  I'm not an LLVM expert; I just know what the SiFive OE LLVM build needs last time I tried it.

Jim

Palmer Dabbelt

unread,
May 10, 2022, 4:25:50 PM5/10/22
to Jim Wilson, Liviu Ionescu, RISC-V SW Dev, billa.i...@gmail.com
The resources required to build LLVM differ a lot between the release and debug builds, more so than most software.  There's a bunch of info on the internet.


Jim

--
You received this message because you are subscribed to the Google Groups "RISC-V SW Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sw-dev+un...@groups.riscv.org.

Liviu Ionescu

unread,
May 10, 2022, 4:28:09 PM5/10/22
to RISC-V SW Dev, jim.wil...@gmail.com, RISC-V SW Dev, billa.i...@gmail.com, Liviu Ionescu
I don't know how RVV is implemented in LLVM, but in GCC it required quite a lot of memory; this might be another explanation for the linker crash.

Billa Surendra

unread,
May 11, 2022, 5:04:07 AM5/11/22
to Khem Raj, RISC-V SW Dev
On Tue, May 10, 2022 at 11:36 PM Khem Raj <raj....@gmail.com> wrote:
linker is segfaulting after printing bunch of unresolved symbols

collect2: fatal error: ld terminated with signal 11 [Segmentation fault]

So it could be that your system is running out of memory, or perhaps a
linker bug.
it seems you are trying to natively compile llvm on a rv64 machine,
how much RAM do you have on this machine ?

I am running RISC-V Linux Image on QEMU, I have given a 25G RAM size. Can I try with 50G or its sufficient? and also I am using parallelism ninja -j8, is this the reason ?.

Tommy Murphy

unread,
May 11, 2022, 6:42:54 AM5/11/22
to Billa Surendra, Khem Raj, RISC-V SW Dev
> I am running RISC-V Linux Image on QEMU, I have given a 25G RAM size. Can I try with 50G or its sufficient?

You can try but the memory available to QEMU will obviously be constrained by the actual amount of memory on the physical host machine.

Bruce Hoult

unread,
May 11, 2022, 7:29:26 AM5/11/22
to Billa Surendra, Khem Raj, RISC-V SW Dev
-j8 should be just about ok with 50 GB. With only 25 GB limit it to -j4 at most.

You only have to limit the number of simultaneous link jobs, not everything. cmake has a flag for that.

Billa Surendra

unread,
May 13, 2022, 12:53:28 AM5/13/22
to Jim Wilson, RISC-V SW Dev
As you suggested, I have installed libncurses. After installing the ncurses package also I am getting the error like this.

Error:

[0/3493] Building CXX object lib/Demangle/CMakeFiles/LLVMDemangle.dir/MicrosoftDemangleNodes.cpp[6/3493] Building CXX object lib/Demangle/CMakeFiles/LLVMDemangle.dir/MicrosoftDemangleNodes.cpp[53/3493] Building CXX object lib/Support/CMakeFiles/LLVMSupport.dir/ItaniumManglingCanonicalize[93/3493] Building CXX object lib/Support/CMakeFiles/LLVMSupport.dir/ItaniumManglingCanonicalize[100/3493] Building CXX object lib/Support/CMakeFiles/LLVMSupport.dir/SymbolRemappingReader.cpp.[136/3493] Building CXX object lib/TableGen/CMakeFiles/LLVMTableGen.dir/DetailedRecordsBackend.c[144/3493] Building CXX object lib/TableGen/CMakeFiles/LLVMTableGen.dir/TableGenBackendSkeleton.[147/3493] Building CXX object lib/TableGen/CMakeFiles/LLVMTableGen.dir/TGParser.cpp.old[17257]: unhandled signal 11 code 0x1 at 0x0000000000000090 in libbfd-2.38.so[3fc76ee000+dc000]
CPU: 1 PID: 17257 Comm: ld Not tainted 5.4.1 #1
sepc: 0000003fc773f820 ra : 0000003fc773fae4 sp : 0000003fffa105c0
 gp : 00000000001efe70 tp : 0000003fc7560d00 t0 : 0000000000000000
 t1 : 0000003fc771dc7c t2 : 00000000001f140a s0 : 0000000000000002
 s1 : 00000000001f0728 a0 : 000000000020c350 a1 : 0000003fffa10688
 a2 : 000000000143f528 a3 : 000000000000f200 a4 : 0000003fc77d3a60
 a5 : 0000000000000000 a6 : 000000000000000e a7 : 0000000000000003
 s2 : 0000000001448f20 s3 : 0000000000000000 s4 : 00000000014154c0
 s5 : 00000000014232e8 s6 : 00000000000008b8 s7 : 0000003fffa10688
 s8 : 0000000001448ed8 s9 : 000000000143f528 s10: 0000000000000000
 s11: 0000003fc77d3f28 t3 : 0000003fc775e430 t4 : 0000000000000000
 t5 : 0000000000000001 t6 : 00000000001bda00
sstatus: 0000000000004020 sbadaddr: 0000000000000090 scause: 000000000000000d
[148/3493] Linking CXX shared library lib/libLLVMSupport.so.13
FAILED: lib/libLLVMSupport.so.13
: && /usr/bin/c++ -fPIC -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wno-comment -Wmisleading-indentation -fdiagnostics-color -ffunction-sections -fdata-sections -O3 -DNDEBUG  -Wl,-z,defs -Wl,-z,nodelete   -Wl,-rpath-link,/home/package_building/llvm-project-llvmorg-13.0.0/build/./lib  -Wl,-O3 -Wl,--gc-sections -shared -Wl,-soname,libLLVMSupport.so.13 -o lib/libLLVMSupport.so.13 lib/Support/CMakeFiles/LLVMSupport.dir/AArch64TargetParser.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/ABIBreak.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/ARMTargetParser.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/AMDGPUMetadata.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/APFixedPoint.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/APFloat.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/APInt.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/APSInt.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/ARMBuildAttrs.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/ARMAttributeParser.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/ARMWinEH.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/Allocator.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/AutoConvert.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/BinaryStreamError.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/BinaryStreamReader.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/BinaryStreamRef.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/BinaryStreamWriter.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/BlockFrequency.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/BranchProbability.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/BuryPointer.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/CachePruning.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/circular_raw_ostream.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/Chrono.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/COM.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/CodeGenCoverage.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/CommandLine.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/Compression.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/CRC.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/ConvertUTF.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/ConvertUTFWrapper.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/CrashRecoveryContext.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/DataExtractor.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/Debug.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/DebugCounter.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/DeltaAlgorithm.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/DAGDeltaAlgorithm.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/DJB.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/ELFAttributeParser.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/ELFAttributes.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/Error.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/ErrorHandling.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/ExtensibleRTTI.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/FileCollector.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/FileUtilities.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/FileOutputBuffer.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/FoldingSet.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/FormattedStream.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/FormatVariadic.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/GlobPattern.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/GraphWriter.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/Hashing.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/InitLLVM.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/InstructionCost.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/IntEqClasses.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/IntervalMap.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/ItaniumManglingCanonicalizer.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/JSON.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/KnownBits.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/LEB128.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/LineIterator.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/Locale.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/LockFileManager.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/LowLevelType.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/ManagedStatic.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/MathExtras.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/MemAlloc.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/MemoryBuffer.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/MemoryBufferRef.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/MD5.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/NativeFormatting.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/OptimizedStructLayout.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/Optional.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/Parallel.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/PluginLoader.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/PrettyStackTrace.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/RandomNumberGenerator.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/Regex.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/RISCVAttributes.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/RISCVAttributeParser.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/ScaledNumber.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/ScopedPrinter.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/SHA1.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/SHA256.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/Signposts.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/SmallPtrSet.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/SmallVector.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/SourceMgr.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/SpecialCaseList.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/Statistic.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/StringExtras.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/StringMap.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/StringSaver.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/StringRef.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/SuffixTree.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/SymbolRemappingReader.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/SystemUtils.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/TarWriter.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/TargetParser.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/ThreadPool.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/TimeProfiler.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/Timer.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/ToolOutputFile.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/TrigramIndex.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/Triple.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/Twine.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/TypeSize.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/Unicode.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/UnicodeCaseFold.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/VersionTuple.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/VirtualFileSystem.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/WithColor.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/X86TargetParser.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/YAMLParser.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/YAMLTraits.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/raw_os_ostream.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/raw_ostream.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/regcomp.c.o lib/Support/CMakeFiles/LLVMSupport.dir/regerror.c.o lib/Support/CMakeFiles/LLVMSupport.dir/regexec.c.o lib/Support/CMakeFiles/LLVMSupport.dir/regfree.c.o lib/Support/CMakeFiles/LLVMSupport.dir/regstrlcpy.c.o lib/Support/CMakeFiles/LLVMSupport.dir/xxhash.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/Z3Solver.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/Atomic.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/DynamicLibrary.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/Errno.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/Host.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/Memory.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/Path.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/Process.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/Program.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/RWMutex.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/Signals.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/TargetRegistry.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/ThreadLocal.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/Threading.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/Valgrind.cpp.o lib/Support/CMakeFiles/LLVMSupport.dir/Watchdog.cpp.o  -Wl,-rpath,"\$ORIGIN/../lib"  -lrt  -ldl  -latomic  -lpthread  -lm  /usr/lib64/libz.so  /usr/lib/libcurses.a  lib/libLLVMDemangle.so.13 && :

collect2: fatal error: ld terminated with signal 11 [Segmentation fault]
compilation terminated.

/usr/lib/gcc/riscv64-unknown-linux-gnu/7.3.1/../../../../riscv64-unknown-linux-gnu/bin/ld: /usr/lib/libcurses.a(lib_cur_term.o): relocation R_RISCV_HI20 against `ospeed' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/riscv64-unknown-linux-gnu/7.3.1/../../../../riscv64-unknown-linux-gnu/bin/ld: /usr/lib/libcurses.a(lib_setup.o): relocation R_RISCV_HI20 against `TABSIZE' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/riscv64-unknown-linux-gnu/7.3.1/../../../../riscv64-unknown-linux-gnu/bin/ld: /usr/lib/libcurses.a(lib_ti.o): relocation R_RISCV_HI20 against `cur_term' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/riscv64-unknown-linux-gnu/7.3.1/../../../../riscv64-unknown-linux-gnu/bin/ld: /usr/lib/libcurses.a(lib_tputs.o): relocation R_RISCV_HI20 against `stdout@@GLIBC_2.27' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/riscv64-unknown-linux-gnu/7.3.1/../../../../riscv64-unknown-linux-gnu/bin/ld: /usr/lib/libcurses.a(lib_ttyflags.o): relocation R_RISCV_HI20 against `_nc_prescreen' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/riscv64-unknown-linux-gnu/7.3.1/../../../../riscv64-unknown-linux-gnu/bin/ld: /usr/lib/libcurses.a(name_match.o): relocation R_RISCV_HI20 against `_nc_globals' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/riscv64-unknown-linux-gnu/7.3.1/../../../../riscv64-unknown-linux-gnu/bin/ld: /usr/lib/libcurses.a(read_entry.o): relocation R_RISCV_HI20 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/riscv64-unknown-linux-gnu/7.3.1/../../../../riscv64-unknown-linux-gnu/bin/ld: /usr/lib/libcurses.a(alloc_ttype.o): relocation R_RISCV_HI20 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/riscv64-unknown-linux-gnu/7.3.1/../../../../riscv64-unknown-linux-gnu/bin/ld: /usr/lib/libcurses.a(comp_error.o): relocation R_RISCV_HI20 against `_nc_globals' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/riscv64-unknown-linux-gnu/7.3.1/../../../../riscv64-unknown-linux-gnu/bin/ld: /usr/lib/libcurses.a(comp_userdefs.o): relocation R_RISCV_HI20 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/riscv64-unknown-linux-gnu/7.3.1/../../../../riscv64-unknown-linux-gnu/bin/ld: /usr/lib/libcurses.a(db_iterator.o): relocation R_RISCV_HI20 against `_nc_globals' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/riscv64-unknown-linux-gnu/7.3.1/../../../../riscv64-unknown-linux-gnu/bin/ld: /usr/lib/libcurses.a(entries.o): relocation R_RISCV_HI20 against `_nc_head' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/riscv64-unknown-linux-gnu/7.3.1/../../../../riscv64-unknown-linux-gnu/bin/ld: /usr/lib/libcurses.a(free_ttype.o): relocation R_RISCV_HI20 against `_nc_head' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/riscv64-unknown-linux-gnu/7.3.1/../../../../riscv64-unknown-linux-gnu/bin/ld: /usr/lib/libcurses.a(getenv_num.o): relocation R_RISCV_HI20 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/riscv64-unknown-linux-gnu/7.3.1/../../../../riscv64-unknown-linux-gnu/bin/ld: /usr/lib/libcurses.a(home_terminfo.o): relocation R_RISCV_HI20 against `_nc_globals' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/riscv64-unknown-linux-gnu/7.3.1/../../../../riscv64-unknown-linux-gnu/bin/ld: /usr/lib/libcurses.a(lib_baudrate.o): relocation R_RISCV_HI20 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/riscv64-unknown-linux-gnu/7.3.1/../../../../riscv64-unknown-linux-gnu/bin/ld: /usr/lib/libcurses.a(lib_napms.o): relocation R_RISCV_HI20 against `SP' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/riscv64-unknown-linux-gnu/7.3.1/../../../../riscv64-unknown-linux-gnu/bin/ld: /usr/lib/libcurses.a(lib_options.o): relocation R_RISCV_HI20 against `cur_term' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/riscv64-unknown-linux-gnu/7.3.1/../../../../riscv64-unknown-linux-gnu/bin/ld: /usr/lib/libcurses.a(lib_raw.o): relocation R_RISCV_HI20 against `cur_term' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/riscv64-unknown-linux-gnu/7.3.1/../../../../riscv64-unknown-linux-gnu/bin/ld: /usr/lib/libcurses.a(comp_captab.o): relocation R_RISCV_HI20 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/riscv64-unknown-linux-gnu/7.3.1/../../../../riscv64-unknown-linux-gnu/bin/ld: /usr/lib/libcurses.a(init_keytry.o): relocation R_RISCV_HI20 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/riscv64-unknown-linux-gnu/7.3.1/../../../../riscv64-unknown-linux-gnu/bin/ld: /usr/lib/libcurses.a(lib_has_cap.o): relocation R_RISCV_HI20 against `cur_term' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/riscv64-unknown-linux-gnu/7.3.1/../../../../riscv64-unknown-linux-gnu/bin/ld: /usr/lib/libcurses.a(key_defined.o): relocation R_RISCV_HI20 against `SP' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/riscv64-unknown-linux-gnu/7.3.1/../../../../riscv64-unknown-linux-gnu/bin/ld: unresolvable R_RISCV_CALL relocation against symbol `fopen@@GLIBC_2.27'
/usr/lib/gcc/riscv64-unknown-linux-gnu/7.3.1/../../../../riscv64-unknown-linux-gnu/bin/ld: unresolvable R_RISCV_CALL relocation against symbol `strncpy@@GLIBC_2.27'
/usr/lib/gcc/riscv64-unknown-linux-gnu/7.3.1/../../../../riscv64-unknown-linux-gnu/bin/ld: unresolvable R_RISCV_CALL relocation against symbol `ioctl@@GLIBC_2.27'
/usr/lib/gcc/riscv64-unknown-linux-gnu/7.3.1/../../../../riscv64-unknown-linux-gnu/bin/ld: unresolvable R_RISCV_HI20 relocation against symbol `stdout@@GLIBC_2.27'
/usr/lib/gcc/riscv64-unknown-linux-gnu/7.3.1/../../../../riscv64-unknown-linux-gnu/bin/ld: unresolvable R_RISCV_CALL relocation against symbol `tcgetattr@@GLIBC_2.27'
/usr/lib/gcc/riscv64-unknown-linux-gnu/7.3.1/../../../../riscv64-unknown-linux-gnu/bin/ld: unresolvable R_RISCV_HI20 relocation against symbol `stderr@@GLIBC_2.27'
[149/3493] Building CXX object lib/TableGen/CMakeFiles/LLVMTableGen.dir/DetailedRecordsBackend.c[151/3493] Building CXX object lib/TableGen/CMakeFiles/LLVMTableGen.dir/TableGenBackendSkeleton.[157/3493] Building CXX object lib/TableGen/CMakeFiles/LLVMTableGen.dir/TGParser.cpp.o
ninja: build stopped: subcommand failed.


Please have a look and suggest me.

Jim Wilson

unread,
May 13, 2022, 5:11:59 PM5/13/22
to Billa Surendra, RISC-V SW Dev
On Thu, May 12, 2022 at 9:53 PM Billa Surendra <billa.i...@gmail.com> wrote:
[0/3493] Building CXX object lib/Demangle/CMakeFiles/LLVMDemangle.dir/MicrosoftDemangleNodes.cpp[6/3493] Building CXX object lib/Demangle/CMakeFiles/LLVMDemangle.dir/MicrosoftDemangleNodes.cpp[53/3493] Building CXX object lib/Support/CMakeFiles/LLVMSupport.dir/ItaniumManglingCanonicalize[93/3493] Building CXX object lib/Support/CMakeFiles/LLVMSupport.dir/ItaniumManglingCanonicalize[100/3493] Building CXX object lib/Support/CMakeFiles/LLVMSupport.dir/SymbolRemappingReader.cpp.[136/3493] Building CXX object lib/TableGen/CMakeFiles/LLVMTableGen.dir/DetailedRecordsBackend.c[144/3493] Building CXX object lib/TableGen/CMakeFiles/LLVMTableGen.dir/TableGenBackendSkeleton.[147/3493] Building CXX object lib/TableGen/CMakeFiles/LLVMTableGen.dir/TGParser.cpp.old[17257]: unhandled signal 11 code 0x1 at 0x0000000000000090 in libbfd-2.38.so[3fc76ee000+dc000]
CPU: 1 PID: 17257 Comm: ld Not tainted 5.4.1 #1
sepc: 0000003fc773f820 ra : 0000003fc773fae4 sp : 0000003fffa105c0
 gp : 00000000001efe70 tp : 0000003fc7560d00 t0 : 0000000000000000
 t1 : 0000003fc771dc7c t2 : 00000000001f140a s0 : 0000000000000002
 s1 : 00000000001f0728 a0 : 000000000020c350 a1 : 0000003fffa10688
 a2 : 000000000143f528 a3 : 000000000000f200 a4 : 0000003fc77d3a60
 a5 : 0000000000000000 a6 : 000000000000000e a7 : 0000000000000003
 s2 : 0000000001448f20 s3 : 0000000000000000 s4 : 00000000014154c0
 s5 : 00000000014232e8 s6 : 00000000000008b8 s7 : 0000003fffa10688
 s8 : 0000000001448ed8 s9 : 000000000143f528 s10: 0000000000000000
 s11: 0000003fc77d3f28 t3 : 0000003fc775e430 t4 : 0000000000000000
 t5 : 0000000000000001 t6 : 00000000001bda00
sstatus: 0000000000004020 sbadaddr: 0000000000000090 scause: 000000000000000d

There are many things that could be going wrong here.  You have the binary, and you have the sepc and other registers dumped, so you can try using a debugger to try to figure out exactly where and why it failed.  The sepc is a high address not in the executable, suggesting that this might be a problem with a library such as glibc.  If you have an old glibc, maybe this is a glibc bug that was fixed a few years ago.

You should also check for OOM killer problems, e.g. out-of-memory failures.  If there was one, it should be mentioned in a system log file, exactly where probably depends on whether you use systemd or not.  Or alternatively you can run top or similar in one window while doing the LLVM build in another window and watch the memory usage.

 Or this could be a cascading failure.  It makes sense to fix the easy problems first, and then come back to this one if it still is failing.

/usr/lib/gcc/riscv64-unknown-linux-gnu/7.3.1/../../../../riscv64-unknown-linux-gnu/bin/ld: /usr/lib/libcurses.a(lib_cur_term.o): relocation R_RISCV_HI20 against `ospeed' can not be used when making a shared object; recompile with -fPIC

Like before, this message indicates that you need a libcurses.so file instead of libcurses.a.  Since it is using the full path, maybe this was written into a configuration file somewhere, and you need to rerun the configuration step to tell it that there is now a libncurses.so it should use instead.

/usr/lib/gcc/riscv64-unknown-linux-gnu/7.3.1/../../../../riscv64-unknown-linux-gnu/bin/ld: unresolvable R_RISCV_CALL relocation against symbol `fopen@@GLIBC_2.27'
/usr/lib/gcc/riscv64-unknown-linux-gnu/7.3.1/../../../../riscv64-unknown-linux-gnu/bin/ld: unresolvable R_RISCV_CALL relocation against symbol `strncpy@@GLIBC_2.27'
/usr/lib/gcc/riscv64-unknown-linux-gnu/7.3.1/../../../../riscv64-unknown-linux-gnu/bin/ld: unresolvable R_RISCV_CALL relocation against symbol `ioctl@@GLIBC_2.27'
/usr/lib/gcc/riscv64-unknown-linux-gnu/7.3.1/../../../../riscv64-unknown-linux-gnu/bin/ld: unresolvable R_RISCV_HI20 relocation against symbol `stdout@@GLIBC_2.27'
/usr/lib/gcc/riscv64-unknown-linux-gnu/7.3.1/../../../../riscv64-unknown-linux-gnu/bin/ld: unresolvable R_RISCV_CALL relocation against symbol `tcgetattr@@GLIBC_2.27'
/usr/lib/gcc/riscv64-unknown-linux-gnu/7.3.1/../../../../riscv64-unknown-linux-gnu/bin/ld: unresolvable R_RISCV_HI20 relocation against symbol `stderr@@GLIBC_2.27'

Since only versioned symbols are failing here, this might be a glibc versioning problem, e.g. if you have more than one version of glibc on the system, and something was compiled with the new version, and you tried to link with the old version, then it will fail like this because the old glibc version won't have the symbols required by the new glibc solution.  The solution is to link with the new glibc version instead of the old one.  Otherwise, if you don't have multiple glibc versions, then this could be some kind of cascading failure.  Or it could be an obscure bug somewhere, but try fixing simple stuff first.

Jim
 
Reply all
Reply to author
Forward
0 new messages