Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

riscv64 target llvm error #2014

Open
wizard-lgtm opened this issue Mar 3, 2025 · 4 comments
Open

riscv64 target llvm error #2014

wizard-lgtm opened this issue Mar 3, 2025 · 4 comments
Labels
Enhancement Request New feature or request

Comments

@wizard-lgtm
Copy link

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)
@lerno
Copy link
Collaborator

lerno commented Mar 4, 2025

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.

@wizard-lgtm
Copy link
Author

Too late, i switched back to c

@lerno
Copy link
Collaborator

lerno commented Mar 7, 2025

This is probably the best solution until it is fully supported.

@lerno lerno added the Enhancement Request New feature or request label Mar 10, 2025
@lerno lerno added this to the First release (v1.0) milestone Mar 11, 2025
@wizard-lgtm
Copy link
Author

Can we still compile to riscv64 baremetal (no os)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Request New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants