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

Cross compilation and running of tool and test not working robustly across platforms #3

Closed
ikks opened this issue Nov 25, 2024 · 10 comments · Fixed by #4 or #6
Closed

Cross compilation and running of tool and test not working robustly across platforms #3

ikks opened this issue Nov 25, 2024 · 10 comments · Fixed by #4 or #6

Comments

@ikks
Copy link

ikks commented Nov 25, 2024

Hi there, thank you for this effort, I would like to use lmdb with zig, cross compile and test.
I'm on Debian 12, with zig 0.13.0.

Follows the output

$ zig build tools -Dtarget=x86_64-macos
tools
└─ install mplay
   └─ zig build-exe mplay Debug x86_64-macos
      └─ zig build-lib lmdb Debug x86_64-macos 1 errors
/home/igor/.cache/zig/p/12205c0f7d4ad44b671cf89a7793aafa31ba4739f01b706313e4eadc944b734bd224/libraries/liblmdb/mdb.c:160:10: error: 'resolv.h' file not found
#include <resolv.h> /* defines BYTE_ORDER on HPUX and Solaris */
         ^~~~~~~~~~~
error: warning(compilation): failed to delete '/home/igor/playground/zig/lmdb-options/acbtu/.zig-cache/tmp/4ea43460777dd969-mdb.o.d': FileNotFound

error: the following command failed with 1 compilation errors:
/home/igor/playground/zig/zig-linux-x86_64-0.13.0/zig build-lib -fno-llvm -fno-lld -cflags -pthread -std=c23 -- /home/igor/.cache/zig/p/12205c0f7d4ad44b671cf89a7793aafa31ba4739f01b706313e4eadc944b734bd224/libraries/liblmdb/mdb.c /home/igor/.cache/zig/p/12205c0f7d4ad44b671cf89a7793aafa31ba4739f01b706313e4eadc944b734bd224/libraries/liblmdb/midl.c -fno-strip -fno-sanitize-c -ODebug -target x86_64-macos -mcpu baseline -I /home/igor/.cache/zig/p/12205c0f7d4ad44b671cf89a7793aafa31ba4739f01b706313e4eadc944b734bd224/libraries/liblmdb -D_XOPEN_SOURCE=600 -Mroot -lc --cache-dir /home/igor/playground/zig/lmdb-options/acbtu/.zig-cache --global-cache-dir /home/igor/.cache/zig --name lmdb -static -fno-lto --listen=- 
Build Summary: 1/15 steps succeeded; 1 failed (disable with --summary none)
tools transitive failure
├─ install mdb_copy transitive failure
│  └─ zig build-exe mdb_copy Debug x86_64-macos transitive failure
│     └─ zig build-lib lmdb Debug x86_64-macos 1 errors
├─ install mdb_drop transitive failure
│  └─ zig build-exe mdb_drop Debug x86_64-macos transitive failure
│     └─ zig build-lib lmdb Debug x86_64-macos (reused)
├─ install mdb_dump transitive failure
│  └─ zig build-exe mdb_dump Debug x86_64-macos transitive failure
│     └─ zig build-lib lmdb Debug x86_64-macos (reused)
├─ install mdb_load transitive failure
│  └─ zig build-exe mdb_load Debug x86_64-macos transitive failure
│     └─ zig build-lib lmdb Debug x86_64-macos (reused)
├─ install mdb_stat transitive failure
│  └─ zig build-exe mdb_stat Debug x86_64-macos transitive failure
│     └─ zig build-lib lmdb Debug x86_64-macos (reused)
└─ install mplay transitive failure
   └─ zig build-exe mplay Debug x86_64-macos transitive failure
      └─ zig build-lib lmdb Debug x86_64-macos (reused)
error: the following build command failed with exit code 1:
/home/igor/playground/zig/lmdb-options/acbtu/.zig-cache/o/8b8a090cd1cdbaa98919363df8845d5e/build /home/igor/playground/zig/zig-linux-x86_64-0.13.0/zig /home/igor/playground/zig/lmdb-options/acbtu /home/igor/playground/zig/lmdb-options/acbtu/.zig-cache /home/igor/.cache/zig --seed 0x83b9d081 -Z83ccb1a88b79bbb2 tools -Dtarget=x86_64-macos
@Ultra-Code
Copy link
Collaborator

The issue has been fixed in the latest master commit

@ikks
Copy link
Author

ikks commented Dec 7, 2024

Thank you, it built the tools and they run in darling. Now running the tests I get errors. For windows the cross compiling is not building either.

$ zig build test -fdarling -Dtarget=x86_64-macos --verbose
/home/igor/playground/zig/zig-linux-x86_64-0.13.0/zig build-lib -fno-llvm -fno-lld -cflags -pthread -std=c23 -- /home/igor/.cache/zig/p/12205c0f7d4ad44b671cf89a7793aafa31ba4739f01b706313e4eadc944b734bd224/libraries/liblmdb/mdb.c /home/igor/.cache/zig/p/12205c0f7d4ad44b671cf89a7793aafa31ba4739f01b706313e4eadc944b734bd224/libraries/liblmdb/midl.c -fno-strip -fno-sanitize-c -ODebug -target x86_64-macos -mcpu baseline -I /home/igor/.cache/zig/p/12205c0f7d4ad44b671cf89a7793aafa31ba4739f01b706313e4eadc944b734bd224/libraries/liblmdb -D_XOPEN_SOURCE=600 -D_DARWIN_C_SOURCE= -Mroot -lc --cache-dir /home/igor/playground/zig/lmdb-options/acbtu/.zig-cache --global-cache-dir /home/igor/.cache/zig --name lmdb -static -fno-lto --listen=- 
/home/igor/playground/zig/zig-linux-x86_64-0.13.0/zig build-exe -fno-lld -cflags -pthread -std=c17 -Wno-format -Wno-implicit-function-declaration -- /home/igor/.cache/zig/p/12205c0f7d4ad44b671cf89a7793aafa31ba4739f01b706313e4eadc944b734bd224/libraries/liblmdb/mtest.c /home/igor/playground/zig/lmdb-options/acbtu/.zig-cache/o/af5309c5268b3016e41e0df6a099fb40/liblmdb.a -fno-sanitize-c -ODebug -target x86_64-macos -mcpu baseline -I /home/igor/.cache/zig/p/12205c0f7d4ad44b671cf89a7793aafa31ba4739f01b706313e4eadc944b734bd224/libraries/liblmdb -I /home/igor/playground/zig/lmdb-options/acbtu/.zig-cache/o/d926581394ea455c2cfb25b410d07bd3 -Mroot -lc --cache-dir /home/igor/playground/zig/lmdb-options/acbtu/.zig-cache --global-cache-dir /home/igor/.cache/zig --name mtest --listen=- 
/home/igor/playground/zig/zig-linux-x86_64-0.13.0/zig build-exe -fno-lld -cflags -pthread -std=c17 -Wno-format -Wno-implicit-function-declaration -- /home/igor/.cache/zig/p/12205c0f7d4ad44b671cf89a7793aafa31ba4739f01b706313e4eadc944b734bd224/libraries/liblmdb/mtest3.c /home/igor/playground/zig/lmdb-options/acbtu/.zig-cache/o/af5309c5268b3016e41e0df6a099fb40/liblmdb.a -fno-sanitize-c -ODebug -target x86_64-macos -mcpu baseline -I /home/igor/.cache/zig/p/12205c0f7d4ad44b671cf89a7793aafa31ba4739f01b706313e4eadc944b734bd224/libraries/liblmdb -I /home/igor/playground/zig/lmdb-options/acbtu/.zig-cache/o/d926581394ea455c2cfb25b410d07bd3 -Mroot -lc --cache-dir /home/igor/playground/zig/lmdb-options/acbtu/.zig-cache --global-cache-dir /home/igor/.cache/zig --name mtest3 --listen=- 
/home/igor/playground/zig/zig-linux-x86_64-0.13.0/zig build-exe -fno-lld -cflags -pthread -std=c17 -Wno-format -Wno-implicit-function-declaration -- /home/igor/.cache/zig/p/12205c0f7d4ad44b671cf89a7793aafa31ba4739f01b706313e4eadc944b734bd224/libraries/liblmdb/mtest2.c /home/igor/playground/zig/lmdb-options/acbtu/.zig-cache/o/af5309c5268b3016e41e0df6a099fb40/liblmdb.a -fno-sanitize-c -ODebug -target x86_64-macos -mcpu baseline -I /home/igor/.cache/zig/p/12205c0f7d4ad44b671cf89a7793aafa31ba4739f01b706313e4eadc944b734bd224/libraries/liblmdb -I /home/igor/playground/zig/lmdb-options/acbtu/.zig-cache/o/d926581394ea455c2cfb25b410d07bd3 -Mroot -lc --cache-dir /home/igor/playground/zig/lmdb-options/acbtu/.zig-cache --global-cache-dir /home/igor/.cache/zig --name mtest2 --listen=- 
/home/igor/playground/zig/zig-linux-x86_64-0.13.0/zig build-exe -fno-lld -cflags -pthread -std=c17 -Wno-format -Wno-implicit-function-declaration -- /home/igor/.cache/zig/p/12205c0f7d4ad44b671cf89a7793aafa31ba4739f01b706313e4eadc944b734bd224/libraries/liblmdb/mtest5.c /home/igor/playground/zig/lmdb-options/acbtu/.zig-cache/o/af5309c5268b3016e41e0df6a099fb40/liblmdb.a -fno-sanitize-c -ODebug -target x86_64-macos -mcpu baseline -I /home/igor/.cache/zig/p/12205c0f7d4ad44b671cf89a7793aafa31ba4739f01b706313e4eadc944b734bd224/libraries/liblmdb -I /home/igor/playground/zig/lmdb-options/acbtu/.zig-cache/o/d926581394ea455c2cfb25b410d07bd3 -Mroot -lc --cache-dir /home/igor/playground/zig/lmdb-options/acbtu/.zig-cache --global-cache-dir /home/igor/.cache/zig --name mtest5 --listen=- 
/home/igor/playground/zig/zig-linux-x86_64-0.13.0/zig build-exe -fno-lld -cflags -pthread -std=c17 -Wno-format -Wno-implicit-function-declaration -- /home/igor/.cache/zig/p/12205c0f7d4ad44b671cf89a7793aafa31ba4739f01b706313e4eadc944b734bd224/libraries/liblmdb/mtest4.c /home/igor/playground/zig/lmdb-options/acbtu/.zig-cache/o/af5309c5268b3016e41e0df6a099fb40/liblmdb.a -fno-sanitize-c -ODebug -target x86_64-macos -mcpu baseline -I /home/igor/.cache/zig/p/12205c0f7d4ad44b671cf89a7793aafa31ba4739f01b706313e4eadc944b734bd224/libraries/liblmdb -I /home/igor/playground/zig/lmdb-options/acbtu/.zig-cache/o/d926581394ea455c2cfb25b410d07bd3 -Mroot -lc --cache-dir /home/igor/playground/zig/lmdb-options/acbtu/.zig-cache --global-cache-dir /home/igor/.cache/zig --name mtest4 --listen=- 
cd /home/igor/playground/zig/lmdb-options/acbtu/.zig-cache/o/05bcdd135085d51953865d4916b5f74b && /home/igor/playground/zig/lmdb-options/acbtu/.zig-cache/o/05bcdd135085d51953865d4916b5f74b/mtest2 --listen=- 
cd /home/igor/playground/zig/lmdb-options/acbtu/.zig-cache/o/10108c92fc6788c52269092bb506ba6f && /home/igor/playground/zig/lmdb-options/acbtu/.zig-cache/o/10108c92fc6788c52269092bb506ba6f/mtest --listen=- 
cd /home/igor/playground/zig/lmdb-options/acbtu/.zig-cache/o/00b36cde7f4215889213353bf32613ad && /home/igor/playground/zig/lmdb-options/acbtu/.zig-cache/o/00b36cde7f4215889213353bf32613ad/mtest3 --listen=- 
cd /home/igor/playground/zig/lmdb-options/acbtu/.zig-cache/o/568382e0eaab2540dae61717dff39f57 && /home/igor/playground/zig/lmdb-options/acbtu/.zig-cache/o/568382e0eaab2540dae61717dff39f57/mtest5 --listen=- 
cd /home/igor/playground/zig/lmdb-options/acbtu/.zig-cache/o/10108c92fc6788c52269092bb506ba6f && darling /home/igor/playground/zig/lmdb-options/acbtu/.zig-cache/o/10108c92fc6788c52269092bb506ba6f/mtest --listen=- 
cd /home/igor/playground/zig/lmdb-options/acbtu/.zig-cache/o/05bcdd135085d51953865d4916b5f74b && darling /home/igor/playground/zig/lmdb-options/acbtu/.zig-cache/o/05bcdd135085d51953865d4916b5f74b/mtest2 --listen=- 
cd /home/igor/playground/zig/lmdb-options/acbtu/.zig-cache/o/dfa4aebb5462e4d39725ce36c3cb117b && /home/igor/playground/zig/lmdb-options/acbtu/.zig-cache/o/dfa4aebb5462e4d39725ce36c3cb117b/mtest4 --listen=- 
cd /home/igor/playground/zig/lmdb-options/acbtu/.zig-cache/o/568382e0eaab2540dae61717dff39f57 && darling /home/igor/playground/zig/lmdb-options/acbtu/.zig-cache/o/568382e0eaab2540dae61717dff39f57/mtest5 --listen=- 
cd /home/igor/playground/zig/lmdb-options/acbtu/.zig-cache/o/00b36cde7f4215889213353bf32613ad && darling /home/igor/playground/zig/lmdb-options/acbtu/.zig-cache/o/00b36cde7f4215889213353bf32613ad/mtest3 --listen=- 
cd /home/igor/playground/zig/lmdb-options/acbtu/.zig-cache/o/dfa4aebb5462e4d39725ce36c3cb117b && darling /home/igor/playground/zig/lmdb-options/acbtu/.zig-cache/o/dfa4aebb5462e4d39725ce36c3cb117b/mtest4 --listen=- 
test
└─ run mtest2 failure
/home/igor/.cache/zig/p/12205c0f7d4ad44b671cf89a7793aafa31ba4739f01b706313e4eadc944b734bd224/libraries/liblmdb/mtest2.c:53: mdb_env_open(env, "./testdb", MDB_FIXEDMAP|MDB_NOSYNC, 0664): Invalid argument
error: the following command exited with code 1 (expected exited with code 0):
cd /home/igor/playground/zig/lmdb-options/acbtu/.zig-cache/o/05bcdd135085d51953865d4916b5f74b && darling /home/igor/playground/zig/lmdb-options/acbtu/.zig-cache/o/05bcdd135085d51953865d4916b5f74b/mtest2 --listen=- 
test
└─ run mtest4 failure
/home/igor/.cache/zig/p/12205c0f7d4ad44b671cf89a7793aafa31ba4739f01b706313e4eadc944b734bd224/libraries/liblmdb/mtest4.c:53: mdb_env_open(env, "./testdb", MDB_FIXEDMAP|MDB_NOSYNC, 0664): Invalid argument
error: the following command exited with code 1 (expected exited with code 0):
cd /home/igor/playground/zig/lmdb-options/acbtu/.zig-cache/o/dfa4aebb5462e4d39725ce36c3cb117b && darling /home/igor/playground/zig/lmdb-options/acbtu/.zig-cache/o/dfa4aebb5462e4d39725ce36c3cb117b/mtest4 --listen=- 
test
└─ run mtest failure
/home/igor/.cache/zig/p/12205c0f7d4ad44b671cf89a7793aafa31ba4739f01b706313e4eadc944b734bd224/libraries/liblmdb/mtest.c:50: mdb_env_open(env, "./testdb", MDB_FIXEDMAP , 0664): Invalid argument
error: the following command exited with code 1 (expected exited with code 0):
cd /home/igor/playground/zig/lmdb-options/acbtu/.zig-cache/o/10108c92fc6788c52269092bb506ba6f && darling /home/igor/playground/zig/lmdb-options/acbtu/.zig-cache/o/10108c92fc6788c52269092bb506ba6f/mtest --listen=- 
test
└─ run mtest5 failure
/home/igor/.cache/zig/p/12205c0f7d4ad44b671cf89a7793aafa31ba4739f01b706313e4eadc944b734bd224/libraries/liblmdb/mtest5.c:55: mdb_env_open(env, "./testdb", MDB_FIXEDMAP|MDB_NOSYNC, 0664): Invalid argument
error: the following command exited with code 1 (expected exited with code 0):
cd /home/igor/playground/zig/lmdb-options/acbtu/.zig-cache/o/568382e0eaab2540dae61717dff39f57 && darling /home/igor/playground/zig/lmdb-options/acbtu/.zig-cache/o/568382e0eaab2540dae61717dff39f57/mtest5 --listen=- 
test
└─ run mtest3 failure
/home/igor/.cache/zig/p/12205c0f7d4ad44b671cf89a7793aafa31ba4739f01b706313e4eadc944b734bd224/libraries/liblmdb/mtest3.c:55: mdb_env_open(env, "./testdb", MDB_FIXEDMAP|MDB_NOSYNC, 0664): Invalid argument
error: the following command exited with code 1 (expected exited with code 0):
cd /home/igor/playground/zig/lmdb-options/acbtu/.zig-cache/o/00b36cde7f4215889213353bf32613ad && darling /home/igor/playground/zig/lmdb-options/acbtu/.zig-cache/o/00b36cde7f4215889213353bf32613ad/mtest3 --listen=- 
Build Summary: 12/18 steps succeeded; 5 failed (disable with --summary none)
test transitive failure
├─ run mtest failure
├─ run mtest2 failure
├─ run mtest3 failure
├─ run mtest4 failure
└─ run mtest5 failure
error: the following build command failed with exit code 1:
/home/igor/playground/zig/lmdb-options/acbtu/.zig-cache/o/9c06fcce885bd4b49f2c310ec8dde17a/build /home/igor/playground/zig/zig-linux-x86_64-0.13.0/zig /home/igor/playground/zig/lmdb-options/acbtu /home/igor/playground/zig/lmdb-options/acbtu/.zig-cache /home/igor/.cache/zig --seed 0x78927385 -Zfb0b5f51d28c7661 test -fdarling -Dtarget=x86_64-macos --verbose

Please let me know if it's better to open different issues for each case, the following three are failing:

  • build tools crosscompiling from debian to windows: zig build tools -Dtarget=x86_64-windows
  • running tests from debian to macos cross compiling: zig build test -fdarling -Dtarget=x86_64-macos --verbose
  • running tests from debian to windows cross compiling: zig build test -fwine -Dtarget=x86_64-windows --verbose

Again, thank you.

@Ultra-Code
Copy link
Collaborator

Ultra-Code commented Dec 10, 2024

Let's keep the issues here since they are related. You can modify the Title to better capture the issue. I will create a PR soon so you can test the failing issues out.

Ultra-Code added a commit that referenced this issue Dec 10, 2024
Also ensure one can build on and for windows
Awaiting testing to ensure test run on windows

resolves #3
@Ultra-Code
Copy link
Collaborator

@ikks test out #6 for buiding on and targeting windows. I am still figuring out the macos case because sometimes when I install the test and run them mannually they work once and then don't work again and most time I get the Invalid argument so I have to investigate further.

@ikks
Copy link
Author

ikks commented Dec 10, 2024

@Ultra-Code I can confirm that building tools works without problems in wine issuing zig build tools -Dtarget=x86_64-windows I can run each of the generated commands.

I get

└── zig-out
    ├── bin
    │   ├── mdb_copy
    │   ├── mdb_copy.exe
    │   ├── mdb_copy.pdb
    │   ├── mdb_drop
    │   ├── mdb_drop.exe
    │   ├── mdb_drop.pdb
    │   ├── mdb_dump
    │   ├── mdb_dump.exe
    │   ├── mdb_dump.pdb
    │   ├── mdb_load
    │   ├── mdb_load.exe
    │   ├── mdb_load.pdb
    │   ├── mdb_stat
    │   ├── mdb_stat.exe
    │   ├── mdb_stat.pdb
    │   └── mplay

i@h:acbtu$ wine zig-out/bin/mdb_copy.exe 
it looks like wine32 is missing, you should install it.
as root, please execute "apt-get install wine32:i386"
usage: Z:\home\igor\playground\zig\lmdb-options\acbtu\zig-out\bin\mdb_copy.exe [-V] [-c] [-n] [-v] srcpath [dstpath]
i@h:acbtu$ wine zig-out/bin/mdb_drop.exe 
it looks like wine32 is missing, you should install it.
as root, please execute "apt-get install wine32:i386"
usage: Z:\home\igor\playground\zig\lmdb-options\acbtu\zig-out\bin\mdb_drop.exe [-V] [-n] [-d] [-s subdb] dbpath
i@h:acbtu$ wine zig-out/bin/mdb_dump.exe 
it looks like wine32 is missing, you should install it.
as root, please execute "apt-get install wine32:i386"
usage: Z:\home\igor\playground\zig\lmdb-options\acbtu\zig-out\bin\mdb_dump.exe [-V] [-f output] [-l] [-n] [-p] [-v] [-a|-s subdb] dbpath
i@h:acbtu$ wine zig-out/bin/mdb_stat.exe 
it looks like wine32 is missing, you should install it.
as root, please execute "apt-get install wine32:i386"
usage: Z:\home\igor\playground\zig\lmdb-options\acbtu\zig-out\bin\mdb_stat.exe [-V] [-n] [-e] [-r[r]] [-f[f[f]]] [-v] [-a|-s subdb] dbpath

Thank you.

@ikks
Copy link
Author

ikks commented Dec 10, 2024

But I'm afraid there is a regression for Linux on tools I'm gettting:

$ zig build tools -Dtarget=x86_64-linux --verbose
/home/igor/playground/zig/zig-linux-x86_64-0.13.0/zig build-lib -fno-llvm -fno-lld -cflags -pthread -std=c23 -- /home/igor/.cache/zig/p/12205c0f7d4ad44b671cf89a7793aafa31ba4739f01b706313e4eadc944b734bd224/libraries/liblmdb/mdb.c /home/igor/.cache/zig/p/12205c0f7d4ad44b671cf89a7793aafa31ba4739f01b706313e4eadc944b734bd224/libraries/liblmdb/midl.c -fno-strip -fno-sanitize-c -ODebug -target x86_64-linux -mcpu baseline -I /home/igor/.cache/zig/p/12205c0f7d4ad44b671cf89a7793aafa31ba4739f01b706313e4eadc944b734bd224/libraries/liblmdb -D_XOPEN_SOURCE=600 -Mroot -lc --cache-dir /home/igor/playground/zig/lmdb-options/acbtu/.zig-cache --global-cache-dir /home/igor/.cache/zig --name lmdb -static -fno-lto --listen=- 
/home/igor/playground/zig/zig-linux-x86_64-0.13.0/zig build-exe -fno-llvm -fno-lld -cflags -pthread -std=c23 -- /home/igor/.cache/zig/p/12205c0f7d4ad44b671cf89a7793aafa31ba4739f01b706313e4eadc944b734bd224/libraries/liblmdb/mdb_dump.c /home/igor/playground/zig/lmdb-options/acbtu/.zig-cache/o/c77a71d36d36dcc44242e5a83184ee50/liblmdb.a -fno-strip -fno-sanitize-c -ODebug -target x86_64-linux -mcpu baseline -I /home/igor/.cache/zig/p/12205c0f7d4ad44b671cf89a7793aafa31ba4739f01b706313e4eadc944b734bd224/libraries/liblmdb -I /home/igor/playground/zig/lmdb-options/acbtu/.zig-cache/o/d926581394ea455c2cfb25b410d07bd3 -D_XOPEN_SOURCE=600 -Mroot -lc --cache-dir /home/igor/playground/zig/lmdb-options/acbtu/.zig-cache --global-cache-dir /home/igor/.cache/zig --name mdb_dump --listen=- 
/home/igor/playground/zig/zig-linux-x86_64-0.13.0/zig build-exe -fno-llvm -fno-lld -cflags -pthread -std=c23 -- /home/igor/.cache/zig/p/12205c0f7d4ad44b671cf89a7793aafa31ba4739f01b706313e4eadc944b734bd224/libraries/liblmdb/mdb_stat.c /home/igor/playground/zig/lmdb-options/acbtu/.zig-cache/o/c77a71d36d36dcc44242e5a83184ee50/liblmdb.a -fno-strip -fno-sanitize-c -ODebug -target x86_64-linux -mcpu baseline -I /home/igor/.cache/zig/p/12205c0f7d4ad44b671cf89a7793aafa31ba4739f01b706313e4eadc944b734bd224/libraries/liblmdb -I /home/igor/playground/zig/lmdb-options/acbtu/.zig-cache/o/d926581394ea455c2cfb25b410d07bd3 -D_XOPEN_SOURCE=600 -Mroot -lc --cache-dir /home/igor/playground/zig/lmdb-options/acbtu/.zig-cache --global-cache-dir /home/igor/.cache/zig --name mdb_stat --listen=- 
/home/igor/playground/zig/zig-linux-x86_64-0.13.0/zig build-exe -fno-llvm -fno-lld -cflags -pthread -std=c23 -- /home/igor/.cache/zig/p/12205c0f7d4ad44b671cf89a7793aafa31ba4739f01b706313e4eadc944b734bd224/libraries/liblmdb/mdb_load.c /home/igor/playground/zig/lmdb-options/acbtu/.zig-cache/o/c77a71d36d36dcc44242e5a83184ee50/liblmdb.a -fno-strip -fno-sanitize-c -ODebug -target x86_64-linux -mcpu baseline -I /home/igor/.cache/zig/p/12205c0f7d4ad44b671cf89a7793aafa31ba4739f01b706313e4eadc944b734bd224/libraries/liblmdb -I /home/igor/playground/zig/lmdb-options/acbtu/.zig-cache/o/d926581394ea455c2cfb25b410d07bd3 -D_XOPEN_SOURCE=600 -Mroot -lc --cache-dir /home/igor/playground/zig/lmdb-options/acbtu/.zig-cache --global-cache-dir /home/igor/.cache/zig --name mdb_load --listen=- 
/home/igor/playground/zig/zig-linux-x86_64-0.13.0/zig build-exe -fno-llvm -fno-lld -cflags -pthread -std=c23 -- /home/igor/.cache/zig/p/12205c0f7d4ad44b671cf89a7793aafa31ba4739f01b706313e4eadc944b734bd224/libraries/liblmdb/mdb_copy.c /home/igor/playground/zig/lmdb-options/acbtu/.zig-cache/o/c77a71d36d36dcc44242e5a83184ee50/liblmdb.a -fno-strip -fno-sanitize-c -ODebug -target x86_64-linux -mcpu baseline -I /home/igor/.cache/zig/p/12205c0f7d4ad44b671cf89a7793aafa31ba4739f01b706313e4eadc944b734bd224/libraries/liblmdb -I /home/igor/playground/zig/lmdb-options/acbtu/.zig-cache/o/d926581394ea455c2cfb25b410d07bd3 -D_XOPEN_SOURCE=600 -Mroot -lc --cache-dir /home/igor/playground/zig/lmdb-options/acbtu/.zig-cache --global-cache-dir /home/igor/.cache/zig --name mdb_copy --listen=- 
/home/igor/playground/zig/zig-linux-x86_64-0.13.0/zig build-exe -fno-llvm -fno-lld -cflags -pthread -std=c23 -- /home/igor/.cache/zig/p/12205c0f7d4ad44b671cf89a7793aafa31ba4739f01b706313e4eadc944b734bd224/libraries/liblmdb/mplay.c /home/igor/playground/zig/lmdb-options/acbtu/.zig-cache/o/c77a71d36d36dcc44242e5a83184ee50/liblmdb.a -fno-strip -fno-sanitize-c -ODebug -target x86_64-linux -mcpu baseline -I /home/igor/.cache/zig/p/12205c0f7d4ad44b671cf89a7793aafa31ba4739f01b706313e4eadc944b734bd224/libraries/liblmdb -I /home/igor/playground/zig/lmdb-options/acbtu/.zig-cache/o/d926581394ea455c2cfb25b410d07bd3 -D_XOPEN_SOURCE=600 -Mroot -lc --cache-dir /home/igor/playground/zig/lmdb-options/acbtu/.zig-cache --global-cache-dir /home/igor/.cache/zig --name mplay --listen=- 
/home/igor/playground/zig/zig-linux-x86_64-0.13.0/zig build-exe -fno-llvm -fno-lld -cflags -pthread -std=c23 -- /home/igor/.cache/zig/p/12205c0f7d4ad44b671cf89a7793aafa31ba4739f01b706313e4eadc944b734bd224/libraries/liblmdb/mdb_drop.c /home/igor/playground/zig/lmdb-options/acbtu/.zig-cache/o/c77a71d36d36dcc44242e5a83184ee50/liblmdb.a -fno-strip -fno-sanitize-c -ODebug -target x86_64-linux -mcpu baseline -I /home/igor/.cache/zig/p/12205c0f7d4ad44b671cf89a7793aafa31ba4739f01b706313e4eadc944b734bd224/libraries/liblmdb -I /home/igor/playground/zig/lmdb-options/acbtu/.zig-cache/o/d926581394ea455c2cfb25b410d07bd3 -D_XOPEN_SOURCE=600 -Mroot -lc --cache-dir /home/igor/playground/zig/lmdb-options/acbtu/.zig-cache --global-cache-dir /home/igor/.cache/zig --name mdb_drop --listen=- 
tools
└─ install mplay
   └─ zig build-exe mplay Debug x86_64-linux 2 errors
/home/igor/.cache/zig/p/12205c0f7d4ad44b671cf89a7793aafa31ba4739f01b706313e4eadc944b734bd224/libraries/liblmdb/mplay.c:488:9: error: cannot assign to variable 'stdin' with const-qualified type 'FILE *const' (aka 'struct _IO_FILE *const')
  stdin = fdopen(0, "r");
  ~~~~~~^
/home/igor/playground/zig/zig-linux-x86_64-0.13.0/lib/libc/include/generic-musl/stdio.h:62:20: note: variable 'stdin' declared const here
extern FILE *const stdin;
~~~~~~~~~~~~~~~~~~~^
/home/igor/.cache/zig/p/12205c0f7d4ad44b671cf89a7793aafa31ba4739f01b706313e4eadc944b734bd224/libraries/liblmdb/mplay.c:489:10: error: cannot assign to variable 'stdout' with const-qualified type 'FILE *const' (aka 'struct _IO_FILE *const')
  stdout = fdopen(1, "w");
  ~~~~~~~^
/home/igor/playground/zig/zig-linux-x86_64-0.13.0/lib/libc/include/generic-musl/stdio.h:63:20: note: variable 'stdout' declared const here
extern FILE *const stdout;
~~~~~~~~~~~~~~~~~~~^
error: the following command failed with 2 compilation errors:
/home/igor/playground/zig/zig-linux-x86_64-0.13.0/zig build-exe -fno-llvm -fno-lld -cflags -pthread -std=c23 -- /home/igor/.cache/zig/p/12205c0f7d4ad44b671cf89a7793aafa31ba4739f01b706313e4eadc944b734bd224/libraries/liblmdb/mplay.c /home/igor/playground/zig/lmdb-options/acbtu/.zig-cache/o/c77a71d36d36dcc44242e5a83184ee50/liblmdb.a -fno-strip -fno-sanitize-c -ODebug -target x86_64-linux -mcpu baseline -I /home/igor/.cache/zig/p/12205c0f7d4ad44b671cf89a7793aafa31ba4739f01b706313e4eadc944b734bd224/libraries/liblmdb -I /home/igor/playground/zig/lmdb-options/acbtu/.zig-cache/o/d926581394ea455c2cfb25b410d07bd3 -D_XOPEN_SOURCE=600 -Mroot -lc --cache-dir /home/igor/playground/zig/lmdb-options/acbtu/.zig-cache --global-cache-dir /home/igor/.cache/zig --name mplay --listen=- 
Build Summary: 12/15 steps succeeded; 1 failed (disable with --summary none)
tools transitive failure
└─ install mplay transitive failure
   └─ zig build-exe mplay Debug x86_64-linux 2 errors
error: the following build command failed with exit code 1:
/home/igor/playground/zig/lmdb-options/acbtu/.zig-cache/o/1a321326e5945f148e274f70a9343cff/build /home/igor/playground/zig/zig-linux-x86_64-0.13.0/zig /home/igor/playground/zig/lmdb-options/acbtu /home/igor/playground/zig/lmdb-options/acbtu/.zig-cache /home/igor/.cache/zig --seed 0xdef3745c -Zfb25c20541125046 tools -Dtarget=x86_64-linux --verbose

@Ultra-Code
Copy link
Collaborator

Ultra-Code commented Dec 11, 2024

The issue above is because when an explicit linux target is specified musl libc is used. And in musl libc stdin and stdout are declared as const while they are non const in glibc.

Hmmm, I will try to get a patch that fixes this issue in upstream lmdb but In the meantime I will disable the mplay tool as it isn't portable to windows (.ie it uses 'sys/wait.h' which is a posix system header) and doesn't compile on musl.

@Ultra-Code
Copy link
Collaborator

I have disabled mplay in #6. You could retest.

@Ultra-Code Ultra-Code reopened this Dec 11, 2024
@Ultra-Code Ultra-Code changed the title Cross compilation from Debian 12 to macos missing Cross compilation and running of tool and test not working robustly across platforms Dec 11, 2024
@ikks
Copy link
Author

ikks commented Dec 11, 2024

Confirming that Linux target tools are generated and run correctly, mdb_play is not present as explained
previously. Thanks.

@Ultra-Code
Copy link
Collaborator

Ultra-Code commented Dec 13, 2024

I haven't had enough time to figure out what is causing the Darling test crashes yet, so I will create a new issue to track that. This will allow the linked PR to be merged, closing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants