ivmai / bdwgc

The Boehm-Demers-Weiser conservative C/C++ Garbage Collector (bdwgc, also known as bdw-gc, boehm-gc, libgc)

Home Page:https://www.hboehm.info/gc/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Zig support improvement

ivmai opened this issue · comments

Continuation of #557 and PR #598.

What to improve in build.zig:

  • resolve TODO item: specify PACKAGE_VERSION and LIB*_VER_INFO, convert VER_INFO values to [SO]VERSION ones
  • resolve TODO item: support enable_cplusplus
  • resolve TODO item: support enable_throw_bad_alloc_library
  • resolve TODO item: support build_cord
  • resolve TODO item: compose and install bdw-gc.pc and pkgconfig
  • change test names to have "test" suffix as produced by cmake
  • support MacOS targets
  • support xBSD targets (if really supported by zig)
  • remove -Dbuild_tests options

What to improve in GH Actions:

  • update to zig v0.12 final (when released)
  • support cross-compile for MacOS
  • build and test natively on MacOS
  • support cross-compile for other tier 1 targets
  • test with -Denable_cplusplus

@plajjan It would be very convenient to support CFLAGS_EXTRA option, could you please add it?
See CMakeLists.txt and Makefile.direct for the reference. (I'm not sure we need to separate the arguments in CFLAGS_EXTRA.)

With "replace -Denable_threads=false to -fsingle-threaded", do you mean we should replace the user visible input? I don't think that is possible. I think the idea with zig build is that you don't just let users pass compiler flags straight to the compiler but rather expose them as project specific options (the -D options) and then set compiler flags based on that.

If on the other hand you mean that we should set -fsingle-threaded based on -Denable_threads=false, that should certainly be possible. Zig compilation objects, i.e. libraries and executable, have a single_threaded option on them, that we should probably set. I think that implies -fsingle-threaded down the line.

@ivmai yes, I can add a simple CFLAGS_EXTRA option that just passes through its value to the compiler. I don't see any added value in parsing it to separate arguments etc, so straight pass-through it is! :)

With "replace -Denable_threads=false to -fsingle-threaded", do you mean we should replace the user visible input? I don't think that is possible. I think the idea with zig build is that you don't just let users pass compiler flags straight to the compiler but rather expose them as project specific options (the -D options) and then set compiler flags based on that.

If on the other hand you mean that we should set -fsingle-threaded based on -Denable_threads=false, that should certainly be possible. Zig compilation objects, i.e. libraries and executable, have a single_threaded option on them, that we should probably set. I think that implies -fsingle-threaded down the line.

I mean expose change build.zig to let client build single-threaded library using -fsingle-threaded option (more nature way in zig world if I understand it correctly) instead of -Denable_threads=false option. I.e.:
zig build -fsingle-threaded instead of zig build -Denable_threads=false.
If this possible. Not a big deal, of course.

Similarly, it looks like -Dbuild_tests option is redundant (to build and run the tests we need to pass both this option and test). I think it worth to remove build_tests option.

@ivmai I'm no authoritative zig expert but as far as I know this is not possible. zig build-exe supports -fsingle-threaded but this is for compiling a single zig module / .c into an executable. It is similar to invoking cc directly. With zig build we use zig as a build system and not as a direct compiler, so we are expected to control things like single-threaded through code in build.zig and based on that pass down parameters to the compiler.

Just testing zig build -fsingle-threaded is invalid...

kll@Boxy:~/terastream/acton-deps/bdwgc$ ~/kod/zig/zig-linux-x86_64-0.12.0-dev.2105+60094cc3f/zig build -fsingle-threaded
Unrecognized argument: -fsingle-threaded
...

Okay (about -fsingle-threaded). I am removing it from issue description.

@plajjan Could we make test names as given in cmake script? (hugetest, subthreadcreatetest, etc.)

@ivmai yes, I can add a simple CFLAGS_EXTRA option that just passes through its value to the compiler. I don't see any added value in parsing it to separate arguments etc, so straight pass-through it is! :)

It seems that cmake's separate_arguments() is needed, see #607 (comment)

Similarly, it looks like -Dbuild_tests option is redundant (to build and run the tests we need to pass both this option and test). I think it worth to remove build_tests option.

@plajjan I will remove this option. If you agree it is redundant.

@plajjan Could we make test names as given in cmake script? (hugetest, subthreadcreatetest, etc.)

I'll do it.