riscv64 target llvm error
project.json
{
// Language version of C3.
"langrev": "1",
// Warnings used for all targets.
"warnings": [ "no-unused" ],
// Directories where C3 library files may be found.
"dependency-search-paths": [ "/root/c3/lib" ],
// Libraries to use for all targets.
"dependencies": [ ],
// Authors, optionally with email.
"authors": [ "wizard-lgtm" ],
// Version using semantic versioning.
"version": "0.1.0",
// Sources compiled for all targets.
"sources": [ "src/**" ],
"output": "build",
// Architecture and OS target.
// You can use 'c3c --list-targets' to list all valid targets.
// "target": "windows-x64",
"target": "elf-riscv64", // riscv64
// Targets.
"targets": {
"barebones_c3": {
// Executable or library.
"type": "executable",
// Additional libraries, sources
// and overrides of global settings here.
},
},
// Global settings.
// CPU name, used for optimizations in the LLVM backend.
"cpu": "generic",
// Optimization: "O0", "O1", "O2", "O3", "O4", "O5", "Os", "Oz".
"opt": "O0"
// See resources/examples/project_all_settings.json and 'c3c --list-project-properties' to see more properties.
}
root@DESKTOP-P9MNADN:~/barebones_c3# c3c build --no-entry
WARNING! This architecture is unsupported.
] Assuming non-Posix environment
ld.lld: error: undefined symbol: __divdi3
>>> referenced by math.c3:1021 (/root/c3/lib/std/math/math.c3:1021)
>>> build/obj/elf-riscv64/std.core.mem.o:(std.core.mem.aligned_offset)
>>> referenced by formatter_private.c3:35 (/root/c3/lib/std/io/formatter_private.c3:35)
>>> build/obj/elf-riscv64/std.io.o:(std.io.Formatter.floatformat)
>>> referenced by formatter_private.c3:35 (/root/c3/lib/std/io/formatter_private.c3:35)
>>> build/obj/elf-riscv64/std.io.o:(std.io.Formatter.floatformat)
>>> referenced 3 more times
>>> did you mean: __divti3
>>> defined in: build/obj/elf-riscv64/std.math.o
ld.lld: error: undefined symbol: __muldi3
>>> referenced by math.c3:0 (/root/c3/lib/std/math/math.c3:0)
>>> build/obj/elf-riscv64/std.core.mem.o:(std.core.mem.aligned_offset)
>>> referenced by math_i128.c3:273
>>> build/obj/elf-riscv64/std.math.o:(std.math.__mulddi3)
>>> referenced by math_i128.c3:275
>>> build/obj/elf-riscv64/std.math.o:(std.math.__mulddi3)
>>> referenced 44 more times
>>> did you mean: __multi3
>>> defined in: build/obj/elf-riscv64/std.math.o
ld.lld: error: undefined symbol: __atomic_compare_exchange_1
>>> referenced by atomic_nolibc.c3:37
>>> build/obj/elf-riscv64/std.atomic.o:(__atomic_compare_exchange)
>>> referenced by atomic_nolibc.c3:37
>>> build/obj/elf-riscv64/std.atomic.o:(__atomic_compare_exchange)
>>> referenced by atomic_nolibc.c3:38
>>> build/obj/elf-riscv64/std.atomic.o:(__atomic_compare_exchange)
>>> referenced 12 more times
ld.lld: error: undefined symbol: __atomic_compare_exchange_2
>>> referenced by atomic_nolibc.c3:9
>>> build/obj/elf-riscv64/std.atomic.o:(__atomic_compare_exchange)
>>> referenced by atomic_nolibc.c3:9
>>> build/obj/elf-riscv64/std.atomic.o:(__atomic_compare_exchange)
>>> referenced by atomic_nolibc.c3:9
>>> build/obj/elf-riscv64/std.atomic.o:(__atomic_compare_exchange)
>>> referenced 12 more times
ld.lld: error: undefined symbol: __atomic_compare_exchange_4
>>> referenced by atomic_nolibc.c3:11
>>> build/obj/elf-riscv64/std.atomic.o:(__atomic_compare_exchange)
>>> referenced by atomic_nolibc.c3:11
>>> build/obj/elf-riscv64/std.atomic.o:(__atomic_compare_exchange)
>>> referenced by atomic_nolibc.c3:11
>>> build/obj/elf-riscv64/std.atomic.o:(__atomic_compare_exchange)
>>> referenced 12 more times
ld.lld: error: undefined symbol: __atomic_compare_exchange_8
>>> referenced by builtin.c3:189 (/root/c3/lib/std/core/builtin.c3:189)
>>> build/obj/elf-riscv64/std.atomic.o:(__atomic_compare_exchange)
>>> referenced by builtin.c3:189 (/root/c3/lib/std/core/builtin.c3:189)
>>> build/obj/elf-riscv64/std.atomic.o:(__atomic_compare_exchange)
>>> referenced by builtin.c3:189 (/root/c3/lib/std/core/builtin.c3:189)
>>> build/obj/elf-riscv64/std.atomic.o:(__atomic_compare_exchange)
>>> referenced 12 more times
ld.lld: error: undefined symbol: __eqdf2
>>> referenced by builtin.c3:237 (/root/c3/lib/std/core/builtin.c3:237)
>>> build/obj/elf-riscv64/std.math.o:(std.math._frexp)
>>> referenced by math_builtin.c3:21
>>> build/obj/elf-riscv64/std.math.o:(__powidf2)
>>> referenced by asin.c3:30
>>> build/obj/elf-riscv64/std.math.nolibc.o:(std.math.nolibc._r)
>>> referenced 25 more times
ld.lld: error: undefined symbol: __unorddf2
>>> referenced by builtin.c3:237 (/root/c3/lib/std/core/builtin.c3:237)
>>> build/obj/elf-riscv64/std.math.o:(std.math._frexp)
>>> referenced by math_builtin.c3:21
>>> build/obj/elf-riscv64/std.math.o:(__powidf2)
>>> referenced by asin.c3:30
>>> build/obj/elf-riscv64/std.math.nolibc.o:(std.math.nolibc._r)
>>> referenced 22 more times
ld.lld: error: undefined symbol: __muldf3
>>> referenced by math.c3:1089
>>> build/obj/elf-riscv64/std.math.o:(std.math._frexp)
>>> referenced by math_builtin.c3:18
>>> build/obj/elf-riscv64/std.math.o:(__powidf2)
>>> referenced by math_builtin.c3:19
>>> build/obj/elf-riscv64/std.math.o:(__powidf2)
>>> referenced 203 more times
ld.lld: error: undefined symbol: __divsf3
>>> referenced by math_builtin.c3:6
>>> build/obj/elf-riscv64/std.math.o:(roundevenf)
>>> referenced by asin.c3:30
>>> build/obj/elf-riscv64/std.math.nolibc.o:(std.math.nolibc._r_f)
>>> referenced by asin.c3:31
>>> build/obj/elf-riscv64/std.math.nolibc.o:(std.math.nolibc._r_f.2)
>>> referenced 13 more times
ld.lld: error: undefined symbol: __addsf3
>>> referenced by math.c3:492
>>> build/obj/elf-riscv64/std.math.o:(roundevenf)
>>> referenced by asin.c3:30
>>> build/obj/elf-riscv64/std.math.nolibc.o:(std.math.nolibc._r_f)
>>> referenced by asin.c3:30
>>> build/obj/elf-riscv64/std.math.nolibc.o:(std.math.nolibc._r_f)
>>> referenced 62 more times
ld.lld: error: undefined symbol: __divdf3
>>> referenced by math_builtin.c3:12
>>> build/obj/elf-riscv64/std.math.o:(roundeven)
>>> referenced by math_builtin.c3:21
>>> build/obj/elf-riscv64/std.math.o:(__powidf2)
>>> referenced by asin.c3:30
>>> build/obj/elf-riscv64/std.math.nolibc.o:(std.math.nolibc._r)
>>> referenced 18 more times
ld.lld: error: undefined symbol: __adddf3
>>> referenced by math.c3:492
>>> build/obj/elf-riscv64/std.math.o:(roundeven)
>>> referenced by asin.c3:30
>>> build/obj/elf-riscv64/std.math.nolibc.o:(std.math.nolibc._r)
>>> referenced by asin.c3:30
>>> build/obj/elf-riscv64/std.math.nolibc.o:(std.math.nolibc._r)
>>> referenced 258 more times
ld.lld: error: undefined symbol: __udivdi3
>>> referenced by math_i128.c3:7
>>> build/obj/elf-riscv64/std.math.o:(__divti3)
>>> referenced by math_i128.c3:7
>>> build/obj/elf-riscv64/std.math.o:(__divti3)
>>> referenced by math_i128.c3:8
>>> build/obj/elf-riscv64/std.math.o:(__divti3)
>>> referenced 4 more times
ld.lld: error: undefined symbol: __umoddi3
>>> referenced by math_i128.c3:15
>>> build/obj/elf-riscv64/std.math.o:(__umodti3)
>>> referenced by math_i128.c3:16
>>> build/obj/elf-riscv64/std.math.o:(__umodti3)
>>> referenced by math_i128.c3:16
>>> build/obj/elf-riscv64/std.math.o:(__umodti3)
ld.lld: error: undefined symbol: __mulsf3
>>> referenced by asin.c3:30
>>> build/obj/elf-riscv64/std.math.nolibc.o:(std.math.nolibc._r_f)
>>> referenced by asin.c3:30
>>> build/obj/elf-riscv64/std.math.nolibc.o:(std.math.nolibc._r_f)
>>> referenced by asin.c3:30
>>> build/obj/elf-riscv64/std.math.nolibc.o:(std.math.nolibc._r_f)
>>> referenced 50 more times
ld.lld: error: undefined symbol: __eqsf2
>>> referenced by asin.c3:30
>>> build/obj/elf-riscv64/std.math.nolibc.o:(std.math.nolibc._r_f)
>>> referenced by asin.c3:31
>>> build/obj/elf-riscv64/std.math.nolibc.o:(std.math.nolibc._r_f.2)
>>> referenced by log1p.c3:0
>>> build/obj/elf-riscv64/std.math.nolibc.o:(log1pf)
>>> referenced 10 more times
ld.lld: error: undefined symbol: __unordsf2
>>> referenced by asin.c3:30
>>> build/obj/elf-riscv64/std.math.nolibc.o:(std.math.nolibc._r_f)
>>> referenced by asin.c3:31
>>> build/obj/elf-riscv64/std.math.nolibc.o:(std.math.nolibc._r_f.2)
>>> referenced by log1p.c3:0
>>> build/obj/elf-riscv64/std.math.nolibc.o:(log1pf)
>>> referenced 10 more times
ld.lld: error: undefined symbol: __gedf2
>>> referenced by asin.c3:31
>>> build/obj/elf-riscv64/std.math.nolibc.o:(std.math.nolibc._exp2_specialcase)
>>> referenced by rempi.c3:138
>>> build/obj/elf-riscv64/std.math.nolibc.o:(std.math.nolibc.__rem_pio2_large)
>>> referenced by rempi.c3:142
>>> build/obj/elf-riscv64/std.math.nolibc.o:(std.math.nolibc.__rem_pio2_large)
ld.lld: error: undefined symbol: __subdf3
>>> referenced by asin.c3:31
>>> build/obj/elf-riscv64/std.math.nolibc.o:(std.math.nolibc._exp2_specialcase)
>>> referenced by asin.c3:31
>>> build/obj/elf-riscv64/std.math.nolibc.o:(std.math.nolibc._exp2_specialcase)
>>> referenced by asin.c3:31
>>> build/obj/elf-riscv64/std.math.nolibc.o:(std.math.nolibc._exp2_specialcase)
>>> referenced 106 more times
ld.lld: error: too many errors emitted, stopping now (use --error-limit=0 to see all errors)
Failed to create an executable: (null)
Yes, it's probably quite a bit of work to make it behave properly. For now, you can avoid all of this by using --use-stdlib=no. This will not include the stdlib, but you'll be able to make progress.
This is probably the best solution until it is fully supported.
Ok, the problem was that it defaulted to rv32i / rv64i. If you have a processor with multiply, you need to specify it. You now can do --cpu-flags +m to enable multiplication. More can be added as needed. I have another task here to fix to give some nice defaults.
--riscv-cpu is now added as way to quickly set a good default. With this I consider this done. Can you try it?
Any update?