stoneface86 / tbc

Trackerboy compiler. Command line front end for libtrackerboy
MIT License
3 stars 0 forks source link

Compilation failure #1

Open ISSOtm opened 2 months ago

ISSOtm commented 2 months ago

OS: Arch Linux Nim: 2.0.4 tbc: 39de6deccf040aba13bb8b4622019c991622bc88

tbc_d/@m..@s..@s.nimble@spkgs2@slibtrackerboy-0.8.3-2e68819492b14e5c28065f9ae0d34ac2855bb146@slibtrackerboy@sdata.nim.c:574:76: error: assignment to ‘tySequence__dqTeMBuhLIpwhdlzh4iN9cw_Content *’ from incompatible pointer type ‘tySequence__atzPT9bqVZh26epu1UBlGdg_Content *’ [-Wincompatible-pointer-types]
  574 | (642);    nimln_(643);    result.data.len = 1; result.data.p = (tySequence__atzPT9bqVZh26epu1UBlGdg_Content*) newSeqPayload(1, sizeof(tyArray__H8qf9bpC2ziYA2earmO8m7w), NIM_ALIGNOF(tyArray__H8qf9bpC2ziYA2earmO8m7w));
      |                                                              ^
ISSOtm commented 2 months ago

I've figured out that building with Clang 18.1.8 instead of GCC 14.1.1 compiles fine... this looks like a Nim problem, actually :/

Here is the C compiler invocation:

gcc -c  -w -fmax-errors=3 -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions         -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security         -fstack-clash-protection -fcf-protection -pthread   -I/usr/lib/nim/lib -Itbc -o tbc_d/@m..@s..@s.nimble@spkgs2@slibtrackerboy-0.8.3-2e68819492b14e5c28065f9ae0d34ac2855bb146@slibtrackerboy@sdata.nim.c.o tbc_d/@m..@s..@s.nimble@spkgs2@slibtrackerboy-0.8.3-2e68819492b14e5c28065f9ae0d34ac2855bb146@slibtrackerboy@sdata.nim.c
stoneface86 commented 2 months ago

This was an issue with libtrackerboy when compiling with Nim 2.0.0. I'm not sure the exact issue that causes this but I can tell it's triggered on line 634 in data.nim, seems to be some problem regarding seqs. The issue has been fixed for libtrackerboy v0.9.0, but tbc currently depends on v0.8.3.

The latest stable version from the 1.6 line should compile successfully, but I guess not using GCC also works for some reason.

stoneface86 commented 2 months ago

Ah, seems related to an issue I submitted earlier - https://github.com/nim-lang/Nim/issues/23489

Compiling this example results in the same compile error with GCC:


type
  Bar = enum
    b1, b2, b3, b4

  Foo = object
    data: seq[array[Bar, uint8]]

func foo(): Foo =
  Foo(data: @[[1u8, 2, 3, 4]])

let f = foo()
echo f

Results in:

Hint: used config file '/home/bit/files/toolchains/nim-2.0.4/config/nim.cfg' [Conf]
Hint: used config file '/home/bit/files/toolchains/nim-2.0.4/config/config.nims' [Conf]
Hint: used config file '/home/bit/.config/nim/config.nims' [Conf]
......................................................................
CC: bugSeq.nim
/mnt/ramdisk/nimcache/2.0.4/d/bugSeq/@mbugSeq.nim.c: In function ‘foo__bug83eq_u11’:
/mnt/ramdisk/nimcache/2.0.4/d/bugSeq/@mbugSeq.nim.c:121:60: error: assignment to ‘tySequence__g3EI7rrcd3g3rGYXxJMgKA_Content *’ from incompatible pointer type ‘tySequence__atzPT9bqVZh26epu1UBlGdg_Content *’ [-Wincompatible-pointer-types]
  121 |         nimln_(11);     result.data.len = 1; result.data.p = (tySequence__atzPT9bqVZh26epu1UBlGdg_Content*) newSeqPayload(1, sizeof(tyArray__H8qf9bpC2ziYA2earmO8m7w), NIM_ALIGNOF(tyArray__H8qf9bpC2ziYA2earmO8m7w));
      |                                                            ^
Error: execution of an external compiler program 'gcc -c  -w -fmax-errors=3 -pthread   -I/home/bit/files/toolchains/nim-2.0.4/lib -I/mnt/ramdisk -o /mnt/ramdisk/nimcache/2.0.4/d/bugSeq/@mbugSeq.nim.c.o /mnt/ramdisk/nimcache/2.0.4/d/bugSeq/@mbugSeq.nim.c' failed with exit code: 1