oridb / mc

Myrddin Compiler
MIT License
387 stars 34 forks source link

Build failures on MacOS 10.14.4 #190

Closed typeless closed 4 years ago

typeless commented 5 years ago

Is that because I cannot declare pkg ... in a file along with main?

The code:

use std
use testr

pkg dfspath =
        type dfspath = struct
                source  : int
                marked  : std.bitset#
                adj     : int[:][:]
                graph   : int[:][:]
        ;;

        const mkdfspath : (g : int[:][:], s : int -> dfspath)
        const dfspathfree : (dp : dfspath -> void)
;;

const mkdfspath = {g, s
        var dp

        dp.source = s
        dp.marked = std.mkbs()
        dp.adj = std.slzalloc(g.len)
        dp.graph = g
        -> dp
}

const dfspathfree = {dp
        std.slfree(dp.adj)
        std.bsfree(dp.marked)
}
const main = {
        testr.run([
                [.name = "mytest", .fn = test1]
        ][:])
}

const test1 = {ctx
        const s1 = [
                .[0] = [1, 2][:],
                .[1] = [2, 0][:],
                .[2] = [0, 1][:],
        ][:]

        std.put("Hello World\n")
        testr.ok(ctx)
}

The error log:

 ~/src/local/myr/testr-example  ⑂ master +    mbld test
        ld -pagezero_size 0x100000000 -macosx_version_min 10.6 -o obj/mytest /Users/mura/src/local/myr/mc/out/lib/myr/_myrrt.o obj/test.o -ltestr -lstd -L/Users/mura/src/local/myr/mc/out/lib/myr -lsys -macosx_version_min 10.6
Undefined symbols for architecture x86_64:
  "___fini__", referenced from:
      start in _myrrt.o
  "___init__", referenced from:
      start in _myrrt.o
  "_main", referenced from:
      start in _myrrt.o
  "_std$envlck", referenced from:
      _std$setenv in libstd.a(env.o)
      .L68 in libstd.a(env.o)
      _std$envinit in libstd.a(env.o)
      .L70 in libstd.a(env.o)
      .L77 in libstd.a(env.o)
  "_std$lock", referenced from:
      .L62 in libstd.a(bytealloc.o)
      .L58 in libstd.a(bytealloc.o)
      .L67 in libstd.a(bytealloc.o)
      .L74 in libstd.a(bytealloc.o)
      _std$bigalloc in libstd.a(bytealloc.o)
      _std$bigfree in libstd.a(bytealloc.o)
      _std$setenv in libstd.a(env.o)
      ...
  "_std$memlck", referenced from:
      .L62 in libstd.a(bytealloc.o)
      .L58 in libstd.a(bytealloc.o)
      .L67 in libstd.a(bytealloc.o)
      .L74 in libstd.a(bytealloc.o)
      _std$bigalloc in libstd.a(bytealloc.o)
      .L80 in libstd.a(bytealloc.o)
      _std$bigfree in libstd.a(bytealloc.o)
      ...
  "_std$unlock", referenced from:
      .L62 in libstd.a(bytealloc.o)
      .L58 in libstd.a(bytealloc.o)
      .L67 in libstd.a(bytealloc.o)
      .L74 in libstd.a(bytealloc.o)
      .L80 in libstd.a(bytealloc.o)
      .L119 in libstd.a(bytealloc.o)
      .L68 in libstd.a(env.o)
      ...
ld: symbol(s) not found for inferred architecture x86_64
FAIL: ld -pagezero_size 0x100000000 -macosx_version_min 10.6 -o obj/mytest /Users/mura/src/local/myr/mc/out/lib/myr/_myrrt.o obj/test.o -ltestr -lstd -L/Users/mura/src/local/myr/mc/out/lib/myr -lsys -macosx_version_min 10.6
typeless commented 5 years ago

This will not happen if I follow the idiomatic way to write tests as the std libs do. A better error message by the compiler would be helpful.

typeless commented 4 years ago

This issue no longer exists.