sunfishcode / eyra

Rust programs written entirely in Rust
Other
773 stars 12 forks source link

Support building with `mimalloc` crate #32

Open polarathene opened 1 year ago

polarathene commented 1 year ago

This is extracted from https://github.com/sunfishcode/eyra/issues/27#issuecomment-1820271259 to track when Eyra has implemented the necessary support for using mimalloc as the global allocator and can successfully build:


mimalloc builds successfully with both -gnu and -musl targets.

However when adding Eyra, the dep to libmimalloc-sys fails to build:

error: linking with `cc` failed: exit status: 1

...

  = note: /usr/bin/ld: /tmp/rustc5zEoNy/liblibmimalloc_sys-4ddef3846abe8639.rlib(static.o): in function `_mi_fputs':
          static.c:(.text._mi_fputs+0x1d): undefined reference to `stdout'
          /usr/bin/ld: static.c:(.text._mi_fputs+0x29): undefined reference to `stderr'
          /usr/bin/ld: /tmp/rustc5zEoNy/liblibmimalloc_sys-4ddef3846abe8639.rlib(static.o): in function `mi_vfprintf.part.0':
          static.c:(.text.mi_vfprintf.part.0+0x48): undefined reference to `__vsnprintf_chk'
          /usr/bin/ld: /tmp/rustc5zEoNy/liblibmimalloc_sys-4ddef3846abe8639.rlib(static.o): in function `mi_printf_amount.constprop.0':
          static.c:(.text.mi_printf_amount.constprop.0+0xa5): undefined reference to `__snprintf_chk'
          /usr/bin/ld: static.c:(.text.mi_printf_amount.constprop.0+0x142): undefined reference to `__snprintf_chk'
          /usr/bin/ld: static.c:(.text.mi_printf_amount.constprop.0+0x172): undefined reference to `__snprintf_chk'
          /usr/bin/ld: /tmp/rustc5zEoNy/liblibmimalloc_sys-4ddef3846abe8639.rlib(static.o): in function `mi_vfprintf_thread.constprop.0':
          static.c:(.text.mi_vfprintf_thread.constprop.0+0x6b): undefined reference to `__snprintf_chk'
          /usr/bin/ld: /tmp/rustc5zEoNy/liblibmimalloc_sys-4ddef3846abe8639.rlib(static.o): in function `_mi_prim_numa_node_count':
          static.c:(.text._mi_prim_numa_node_count+0x4d): undefined reference to `__snprintf_chk'
          /usr/bin/ld: /tmp/rustc5zEoNy/liblibmimalloc_sys-4ddef3846abe8639.rlib(static.o): in function `_mi_prim_process_info':
          static.c:(.text._mi_prim_process_info+0x28): undefined reference to `getrusage'
          /usr/bin/ld: /tmp/rustc5zEoNy/liblibmimalloc_sys-4ddef3846abe8639.rlib(static.o): in function `_mi_prim_out_stderr':
          static.c:(.text._mi_prim_out_stderr+0x7): undefined reference to `stderr'
          /usr/bin/ld: static.c:(.text._mi_prim_out_stderr+0xf): undefined reference to `fputs'
          /usr/bin/ld: /tmp/rustc5zEoNy/liblibmimalloc_sys-4ddef3846abe8639.rlib(static.o): in function `mi_option_get':
          static.c:(.text.mi_option_get+0x193): undefined reference to `strtol'
          collect2: error: ld returned 1 exit status

  = note: some `extern` functions couldn't be found; some native libraries may need to be installed or have their path specified
  = note: use the `-l` flag to specify native libraries to link

I'm just reporting this because I encountered it when experimenting with #27 , no actual need for this support any time soon 👍

sunfishcode commented 12 months ago

fputs, stdout, stderr, __snprintf_chk, __vsnprintf_chk, are now implemented.

That leaves: