This was tested under rv64gc.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
It could be built via
$CC=clang CXX=clang++ cmake -DLLVM_ENABLE_RUNTIMES=libc -DCMAKE_INSTALL_PREFIX=/home/advancedwebdeveloper/libc_install -DCMAKE_BUILD_TYPE=MinSizeRel ../llvm-project-main/runtimes
Caught this error:
Scanning dependencies of target libc.src.fenv.fedisableexcept
[ 16%] Building CXX object libc/src/fenv/CMakeFiles/libc.src.fenv.fedisableexcept.dir/fedisableexcept.cpp.o
/home/advancedwebdeveloper/llvm-project-main/libc/src/fenv/fedisableexcept.cpp:16:10: error: no member named 'disable_except' in namespace '__llvm_libc::fputil'; did you mean 'fedisableexcept'?return fputil::disable_except(e); ^~~~~~~~~~~~~~~~~~~~~~ fedisableexcept/home/advancedwebdeveloper/llvm-project-main/libc/src/fenv/fedisableexcept.cpp:15:25: note: 'fedisableexcept' declared here
LLVM_LIBC_FUNCTION(int, fedisableexcept, (int e)) {^1 error generated.
make[2]: * [libc/src/fenv/CMakeFiles/libc.src.fenv.fedisableexcept.dir/build.make:82: libc/src/fenv/CMakeFiles/libc.src.fenv.fedisableexcept.dir/fedisableexcept.cpp.o] Error 1
make[1]: * [CMakeFiles/Makefile2:6945: libc/src/fenv/CMakeFiles/libc.src.fenv.fedisableexcept.dir/all] Error 2
make: *** [Makefile:149: all] Error 2
so entrypoints.txt was modified.
Please elaborate the cause.
Another error:
Scanning dependencies of target libc.src.math.fma [ 18%] Building CXX object libc/src/math/CMakeFiles/libc.src.math.fma.dir/fma.cpp.o /home/advancedwebdeveloper/llvm-project-main/libc/src/math/fma.cpp:17:10: error: no matching function for call to 'fma' return fputil::fma(x, y, z); ^~~~~~~~~~~ /home/advancedwebdeveloper/llvm-project-main/libc/src/__support/FPUtil/FMA.h:33:66: note: candidate template ignored: substitution failure [with T = double]: implicit instantiation of undefined template '__llvm_libc::cpp::EnableIf<false, double>' static inline cpp::EnableIfType<cpp::IsSame<T, float>::Value, T> fma(T x, T y, ^ 1 error generated. make[2]: *** [libc/src/math/CMakeFiles/libc.src.math.fma.dir/build.make:82: libc/src/math/CMakeFiles/libc.src.math.fma.dir/fma.cpp.o] Error 1 make[1]: *** [CMakeFiles/Makefile2:8306: libc/src/math/CMakeFiles/libc.src.math.fma.dir/all] Error 2
Can you sync pass https://reviews.llvm.org/rGee8992770754d186c9217d35cccd339efc55a36b to see if this error still persists?
You might need to add some entrypoints for libc/config/<OS>/<arch>/entrypoints.txt and headers.txt similar to https://reviews.llvm.org/rG0f031daea8fc01ce44766f07b0f4c626ef28f8f5
@sivachandra could add more info about what else are missing.
libc/cmake/modules/LLVMLibCArchitectures.cmake | ||
---|---|---|
21 ↗ | (On Diff #436143) | This looks fishy. It is definitely not a Power Core. |
As @lntue has pointed out, the way start a new port would be to start with an entrypoints.txt and stick to default build. Default build is the mode in which one uses headers from the system libc. You can copy the entrypoints.txt for aarch64 and start peeling away entrypoints until you are able to build and test the remaining. In one of your messages, I see that you are hitting errors with fenv functions. Remove them from your entrypoints.txt as they are target CPU specific implementations. To keep it easy, start with only string.h and math.h functions.
You will be able to work through all that and get it working eventually I would think. But, a more important question to address is the CI story. If you want to land any RISC-V configs/changes, we should have a CI bot connected to LLVM buildbot. It can be a chicken-and-egg problem as to which should go first - the bot or the first patch. We will let the patch go in first, but we will want a time-bound plan to put in place the CI bot before landing more patches. For more information on adding bots connected to LLVM buildbot, see this: https://llvm.org/docs/HowToAddABuilder.html
Still not able to patch:
https://reviews.llvm.org/D127575
Can someone explain LLVM_LIBC_CACHELINE_SIZE ?
libc/cmake/modules/LLVMLibCArchitectures.cmake | ||
---|---|---|
21 ↗ | (On Diff #436143) | Perhaps LIBC_TARGET_ARCHITECTURE_IS_RISCV makes sense here? |
Can someone explain LLVM_LIBC_CACHELINE_SIZE ?
It is supposed to be the cache line size of the processor. As the comments here suggest, they are mostly best effort numbers: https://github.com/llvm/llvm-project/blob/main/libc/src/string/memory_utils/utils.h#L14
Expect that my mistakes where corrected and all files where formatted properly (git-clang-format)
I see a large number of syscall dependent entrypoints in your entrypoints.txt file. Without a RISCV syscall implementation they would fail. Did you run check-libc at all? If yes, and if you did get a clean run, can you share the output?
I was using "make":
[ 95%] Built target libcMPFRWrapper
[100%] Linking CXX executable libc_str_to_float_comparison_test
Test the strtof and strtod implementations against precomputed results.
Starting file /home/advancedwebdeveloper/llvm-project/libc/test/src/__support/str_to_float_comparison_data.txt
Results:
Total significant failed conversions: 0
Total conversions off by +/- 1 bit: 0
0 float low
0 float high
0 double low
0 double high
Total lines: 6
[100%] Built target libc_str_to_float_comparison_test
and able to execute an "install" target:
[ 95%] Built target llvmlibc
[ 95%] Built target libc_system_str_to_float_comparison_test
[100%] Built target libc_str_to_float_comparison_test
Install the project...
- Install configuration: "MinSizeRel"
- Installing: /home/advancedwebdeveloper/libc_install/lib/libllvmlibc.a
Can you share the elf header for one of the object files in libllvmlibc.a. Also, can you share the list of files in libllvmlibc.a? The way to do it would be do:
readelf -asW <path/to/libllvmlibc.a> | grep "File: "
I see this:
advancedwebdeveloper@ubuntu:~/libc_install/lib$ readelf -asW libllvmlibc.a | grep "File: "
File: libllvmlibc.a(isalnum.cpp.o)
File: libllvmlibc.a(isalpha.cpp.o)
File: libllvmlibc.a(isascii.cpp.o)
File: libllvmlibc.a(isblank.cpp.o)
File: libllvmlibc.a(iscntrl.cpp.o)
File: libllvmlibc.a(isdigit.cpp.o)
File: libllvmlibc.a(isgraph.cpp.o)
File: libllvmlibc.a(islower.cpp.o)
File: libllvmlibc.a(isprint.cpp.o)
File: libllvmlibc.a(ispunct.cpp.o)
File: libllvmlibc.a(isspace.cpp.o)
File: libllvmlibc.a(isupper.cpp.o)
File: libllvmlibc.a(isxdigit.cpp.o)
File: libllvmlibc.a(toascii.cpp.o)
File: libllvmlibc.a(tolower.cpp.o)
File: libllvmlibc.a(toupper.cpp.o)
File: libllvmlibc.a(creat.cpp.o)
File: libllvmlibc.a(dummy_errno.cpp.o)
File: libllvmlibc.a(open.cpp.o)
File: libllvmlibc.a(openat.cpp.o)
File: libllvmlibc.a(bcmp.cpp.o)
File: libllvmlibc.a(bzero.cpp.o)
File: libllvmlibc.a(memccpy.cpp.o)
File: libllvmlibc.a(memchr.cpp.o)
File: libllvmlibc.a(memcmp.cpp.o)
File: libllvmlibc.a(memcpy.cpp.o)
File: libllvmlibc.a(memmove.cpp.o)
File: libllvmlibc.a(mempcpy.cpp.o)
File: libllvmlibc.a(memrchr.cpp.o)
File: libllvmlibc.a(memset.cpp.o)
File: libllvmlibc.a(stpcpy.cpp.o)
File: libllvmlibc.a(stpncpy.cpp.o)
File: libllvmlibc.a(strcat.cpp.o)
File: libllvmlibc.a(strcpy.cpp.o)
File: libllvmlibc.a(strchr.cpp.o)
File: libllvmlibc.a(strcmp.cpp.o)
File: libllvmlibc.a(strcspn.cpp.o)
File: libllvmlibc.a(strlcat.cpp.o)
File: libllvmlibc.a(strlcpy.cpp.o)
File: libllvmlibc.a(strlen.cpp.o)
File: libllvmlibc.a(strncat.cpp.o)
File: libllvmlibc.a(strncpy.cpp.o)
File: libllvmlibc.a(strncmp.cpp.o)
File: libllvmlibc.a(strnlen.cpp.o)
File: libllvmlibc.a(strpbrk.cpp.o)
File: libllvmlibc.a(strrchr.cpp.o)
File: libllvmlibc.a(strspn.cpp.o)
File: libllvmlibc.a(strstr.cpp.o)
File: libllvmlibc.a(strtok.cpp.o)
File: libllvmlibc.a(strtok_r.cpp.o)
File: libllvmlibc.a(strdup.cpp.o)
File: libllvmlibc.a(strndup.cpp.o)
File: libllvmlibc.a(imaxdiv.cpp.o)
File: libllvmlibc.a(strtoimax.cpp.o)
File: libllvmlibc.a(strtoumax.cpp.o)
File: libllvmlibc.a(abs.cpp.o)
File: libllvmlibc.a(atoi.cpp.o)
File: libllvmlibc.a(atof.cpp.o)
File: libllvmlibc.a(atol.cpp.o)
File: libllvmlibc.a(atoll.cpp.o)
File: libllvmlibc.a(bsearch.cpp.o)
File: libllvmlibc.a(div.cpp.o)
File: libllvmlibc.a(labs.cpp.o)
File: libllvmlibc.a(ldiv.cpp.o)
File: libllvmlibc.a(llabs.cpp.o)
File: libllvmlibc.a(lldiv.cpp.o)
File: libllvmlibc.a(qsort.cpp.o)
File: libllvmlibc.a(strtod.cpp.o)
File: libllvmlibc.a(strtof.cpp.o)
File: libllvmlibc.a(strtol.cpp.o)
File: libllvmlibc.a(strtold.cpp.o)
File: libllvmlibc.a(strtoll.cpp.o)
File: libllvmlibc.a(strtoul.cpp.o)
File: libllvmlibc.a(strtoull.cpp.o)
File: libllvmlibc.a(mkdir.cpp.o)
File: libllvmlibc.a(mkdirat.cpp.o)
File: libllvmlibc.a(close.cpp.o)
File: libllvmlibc.a(fsync.cpp.o)
File: libllvmlibc.a(lseek.cpp.o)
File: libllvmlibc.a(read.cpp.o)
File: libllvmlibc.a(rmdir.cpp.o)
File: libllvmlibc.a(unlink.cpp.o)
File: libllvmlibc.a(unlinkat.cpp.o)
File: libllvmlibc.a(write.cpp.o)
File: libllvmlibc.a(feclearexcept.cpp.o)
File: libllvmlibc.a(fegetenv.cpp.o)
File: libllvmlibc.a(fegetexceptflag.cpp.o)
File: libllvmlibc.a(fegetround.cpp.o)
File: libllvmlibc.a(fesetenv.cpp.o)
File: libllvmlibc.a(fesetexceptflag.cpp.o)
File: libllvmlibc.a(fesetround.cpp.o)
File: libllvmlibc.a(feraiseexcept.cpp.o)
File: libllvmlibc.a(fetestexcept.cpp.o)
File: libllvmlibc.a(feupdateenv.cpp.o)
File: libllvmlibc.a(copysign.cpp.o)
File: libllvmlibc.a(copysignf.cpp.o)
File: libllvmlibc.a(copysignl.cpp.o)
File: libllvmlibc.a(ceil.cpp.o)
File: libllvmlibc.a(ceilf.cpp.o)
File: libllvmlibc.a(ceill.cpp.o)
File: libllvmlibc.a(cosf.cpp.o)
File: libllvmlibc.a(sincosf_data.cpp.o)
File: libllvmlibc.a(math_utils.cpp.o)
File: libllvmlibc.a(expf.cpp.o)
File: libllvmlibc.a(common_constants.cpp.o)
File: libllvmlibc.a(exp2f.cpp.o)
File: libllvmlibc.a(expm1f.cpp.o)
File: libllvmlibc.a(fabs.cpp.o)
File: libllvmlibc.a(fabsf.cpp.o)
File: libllvmlibc.a(fabsl.cpp.o)
File: libllvmlibc.a(fdim.cpp.o)
File: libllvmlibc.a(fdimf.cpp.o)
File: libllvmlibc.a(fdiml.cpp.o)
File: libllvmlibc.a(floor.cpp.o)
File: libllvmlibc.a(floorf.cpp.o)
File: libllvmlibc.a(floorl.cpp.o)
File: libllvmlibc.a(fmaf.cpp.o)
File: libllvmlibc.a(fmax.cpp.o)
File: libllvmlibc.a(fmaxf.cpp.o)
File: libllvmlibc.a(fmaxl.cpp.o)
File: libllvmlibc.a(fmin.cpp.o)
File: libllvmlibc.a(fminf.cpp.o)
File: libllvmlibc.a(fminl.cpp.o)
File: libllvmlibc.a(frexp.cpp.o)
File: libllvmlibc.a(frexpf.cpp.o)
File: libllvmlibc.a(frexpl.cpp.o)
File: libllvmlibc.a(hypot.cpp.o)
File: libllvmlibc.a(hypotf.cpp.o)
File: libllvmlibc.a(ilogb.cpp.o)
File: libllvmlibc.a(ilogbf.cpp.o)
File: libllvmlibc.a(ilogbl.cpp.o)
File: libllvmlibc.a(llrint.cpp.o)
File: libllvmlibc.a(llrintf.cpp.o)
File: libllvmlibc.a(llrintl.cpp.o)
File: libllvmlibc.a(llround.cpp.o)
File: libllvmlibc.a(llroundf.cpp.o)
File: libllvmlibc.a(llroundl.cpp.o)
File: libllvmlibc.a(lrint.cpp.o)
File: libllvmlibc.a(lrintf.cpp.o)
File: libllvmlibc.a(lrintl.cpp.o)
File: libllvmlibc.a(lround.cpp.o)
File: libllvmlibc.a(lroundf.cpp.o)
File: libllvmlibc.a(lroundl.cpp.o)
File: libllvmlibc.a(ldexp.cpp.o)
File: libllvmlibc.a(ldexpf.cpp.o)
File: libllvmlibc.a(ldexpl.cpp.o)
File: libllvmlibc.a(log10f.cpp.o)
File: libllvmlibc.a(log1pf.cpp.o)
File: libllvmlibc.a(log2f.cpp.o)
File: libllvmlibc.a(logf.cpp.o)
File: libllvmlibc.a(logb.cpp.o)
File: libllvmlibc.a(logbf.cpp.o)
File: libllvmlibc.a(logbl.cpp.o)
File: libllvmlibc.a(modf.cpp.o)
File: libllvmlibc.a(modff.cpp.o)
File: libllvmlibc.a(modfl.cpp.o)
File: libllvmlibc.a(nearbyint.cpp.o)
File: libllvmlibc.a(nearbyintf.cpp.o)
File: libllvmlibc.a(nearbyintl.cpp.o)
File: libllvmlibc.a(nextafter.cpp.o)
File: libllvmlibc.a(nextafterf.cpp.o)
File: libllvmlibc.a(nextafterl.cpp.o)
File: libllvmlibc.a(remainderf.cpp.o)
File: libllvmlibc.a(remainder.cpp.o)
File: libllvmlibc.a(remainderl.cpp.o)
File: libllvmlibc.a(remquof.cpp.o)
File: libllvmlibc.a(remquo.cpp.o)
File: libllvmlibc.a(remquol.cpp.o)
File: libllvmlibc.a(rint.cpp.o)
File: libllvmlibc.a(rintf.cpp.o)
File: libllvmlibc.a(rintl.cpp.o)
File: libllvmlibc.a(round.cpp.o)
File: libllvmlibc.a(roundf.cpp.o)
File: libllvmlibc.a(roundl.cpp.o)
File: libllvmlibc.a(sincosf.cpp.o)
File: libllvmlibc.a(sinf.cpp.o)
File: libllvmlibc.a(sqrt.cpp.o)
File: libllvmlibc.a(sqrtf.cpp.o)
File: libllvmlibc.a(sqrtl.cpp.o)
File: libllvmlibc.a(trunc.cpp.o)
File: libllvmlibc.a(truncf.cpp.o)
File: libllvmlibc.a(truncl.cpp.o)
File: libllvmlibc.a(mmap.cpp.o)
File: libllvmlibc.a(munmap.cpp.o)
libc/config/linux/riscv/entrypoints.txt | ||
---|---|---|
110 | Mistake: a typo |
That your libllvmlibc.a includes many syscall dependent entrypoints, and that your patch does not include a RISC-V syscall implementation, I am not confident that this is being tested in the correct way. As I requested in an earlier comment, I would like to see the ELF header for one of the object files in libllvmlibc.a. For example, can your share what you see when you run
readelf -asW <path/to/libllvmlibc.a> | head -n 25
When I do objdump -dr <path/to/libllvmlibc.a>, I see this:
/usr/local/google/home/sivachandra/Downloads/libllvmlibc.a(fsync.cpp.o): file format elf64-littleriscv Disassembly of section .text: 0000000000000000 <.text>: 0: 01 00 nop 0000000000000000: R_RISCV_ALIGN *ABS*+0x2 /usr/local/google/home/sivachandra/Downloads/libllvmlibc.a(lseek.cpp.o): file format elf64-littleriscv Disassembly of section .text: 0000000000000000 <.text>: 0: 01 00 nop 0000000000000000: R_RISCV_ALIGN *ABS*+0x2 /usr/local/google/home/sivachandra/Downloads/libllvmlibc.a(read.cpp.o): file format elf64-littleriscv Disassembly of section .text: 0000000000000000 <.text>: 0: 01 00 nop 0000000000000000: R_RISCV_ALIGN *ABS*+0x2 /usr/local/google/home/sivachandra/Downloads/libllvmlibc.a(rmdir.cpp.o): file format elf64-littleriscv Disassembly of section .text: 0000000000000000 <.text>: 0: 01 00 nop 0000000000000000: R_RISCV_ALIGN *ABS*+0x2 /usr/local/google/home/sivachandra/Downloads/libllvmlibc.a(unlink.cpp.o): file format elf64-littleriscv Disassembly of section .text: 0000000000000000 <.text>: 0: 01 00 nop 0000000000000000: R_RISCV_ALIGN *ABS*+0x2 /usr/local/google/home/sivachandra/Downloads/libllvmlibc.a(unlinkat.cpp.o): file format elf64-littleriscv Disassembly of section .text: 0000000000000000 <.text>: 0: 01 00 nop 0000000000000000: R_RISCV_ALIGN *ABS*+0x2 /usr/local/google/home/sivachandra/Downloads/libllvmlibc.a(write.cpp.o): file format elf64-littleriscv Disassembly of section .text: 0000000000000000 <.text>: 0: 01 00 nop 0000000000000000: R_RISCV_ALIGN *ABS*+0x2
And for few other functions, I see this:
/usr/local/google/home/sivachandra/Downloads/libllvmlibc.a(feclearexcept.cpp.o): file format elf64-littleriscv Disassembly of section .text: 0000000000000000 <.text>: 0: 01 00 nop 0000000000000000: R_RISCV_ALIGN *ABS*+0x2 Disassembly of section .text.feclearexcept: 0000000000000000 <feclearexcept>: 0: 01 45 mv a0, zero 2: 82 80 ret /usr/local/google/home/sivachandra/Downloads/libllvmlibc.a(fegetenv.cpp.o): file format elf64-littleriscv Disassembly of section .text: 0000000000000000 <.text>: 0: 01 00 nop 0000000000000000: R_RISCV_ALIGN *ABS*+0x2 Disassembly of section .text.fegetenv: 0000000000000000 <fegetenv>: 0: 01 45 mv a0, zero 2: 82 80 ret /usr/local/google/home/sivachandra/Downloads/libllvmlibc.a(fegetexceptflag.cpp.o): file format elf64-littleriscv Disassembly of section .text: 0000000000000000 <.text>: 0: 01 00 nop 0000000000000000: R_RISCV_ALIGN *ABS*+0x2 Disassembly of section .text.fegetexceptflag: 0000000000000000 <fegetexceptflag>: 0: 23 20 05 00 sw zero, 0(a0) 4: 01 45 mv a0, zero 6: 82 80 ret
If you produced the attached libllvmlibc.a file with just this patch, there is something buggy somewhere and that needs to be fixed separately. With respect to making progress on this patch, please ping back once you have couple of major items addressed:
- You will have trim down the entrypoints.txt until you get a clean check-libc run.
- You will have to provide a time-bound plan for a CI builder.
Mistake: a typo