OrangeC icon indicating copy to clipboard operation
OrangeC copied to clipboard

Update Omake for Linux running

Open chuggafan opened this issue 1 year ago • 126 comments

This is a prototype with some basic changes for linux, this DOES NOT CURRENTLY WORK, and I know this because I haven't tested anything to do with actually capturing process output, this is just some fill-in from before to get some eyeballs on this.

The main thing stopping me from getting anywhere is my complete inability to understand how the dup2 stuff works, and all of the pipe issues, which gets me lost immediately upon trying to understand it, I'm at the point of trying to understand how glibc implements popen and it has also gotten me absolutely nowhere... @GitMensch I assume you have the best eyes to know what in the universe POSIX is supposed to be doing and if I'm on the right track here, because I sure know I don't.

chuggafan avatar Jan 04 '25 05:01 chuggafan

Ok, so I've done some testing, I've figured out how to get the readout from posix_spawn properly, thankfully, it's not too bad, it's just annoying because I have to juggle multiple pipes (for stdout and stdin) on that, and then remember everything, I've actually made a test-program for this because the online documentation is so bad that it's not understandable to a beginning that I'll add here in case someone in the future somehow finds this and wants my work as a reference:

#define _GNU_SOURCE
#include <spawn.h>
#include <unistd.h>
#include <stdio.h>
#include <sys/wait.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <poll.h>
extern char **environ;
int main()
{
    posix_spawn_file_actions_t spawn_actions;
    posix_spawnattr_t attrs;
    posix_spawn_file_actions_init(&spawn_actions);
    posix_spawnattr_init(&attrs);
    pid_t spawned_pid;
    int pipes[2];
    int ret = pipe2(pipes, O_CLOEXEC);
    if (ret != 0)
    {
        printf("Pipe failed\n");
    }
    // Copy stdout to the writable pipe, pipes[0] is the readable pipe. Mirrors stdin vs stdout
    posix_spawn_file_actions_adddup2(&spawn_actions, pipes[1], 1);
    // Ensure pipes close
    posix_spawn_file_actions_addclose(&spawn_actions, pipes[1]);
    posix_spawn_file_actions_addclose(&spawn_actions, pipes[0]);

    ret = posix_spawn(&spawned_pid, "/bin/sh", &spawn_actions, &attrs, (char *const[]){"sh", "-c", "--", "ls /var/", NULL}, environ);
    if (ret)
    {
        printf("Failed to spawn! errno: %d\n", ret);
    }
    posix_spawn_file_actions_destroy(&spawn_actions);
    posix_spawnattr_destroy(&attrs);

    int wait_status = 0;
    do
    {
        wait_status = 0;
        char val[80] = {0};
        struct pollfd polls = {.events = POLLIN, .fd = pipes[0]};
        // Poll for < 100ms, if we timeout on having any data whatsoever, we check if the process is done, if the process is done, exit the read loop.
        int ret = poll(&polls, 1, 100);
        if (ret > 0)
        {
            if (polls.revents & POLLIN)
            {
                int success = read(pipes[0], val, sizeof(val) - 1);
                printf("%s", val);
                if (success < 1)
                {
                    break;
                }
            }
        }
        if (ret == 0)
        {
            waitpid(spawned_pid, &wait_status, WUNTRACED);
            if (!(!WIFEXITED(wait_status) && !WIFSIGNALED(wait_status) && !WIFSTOPPED(wait_status)))
            {
                break;
            }
        }
    } while (1);
    close(pipes[0]);
    close(pipes[1]);
}

I have verified in WSL that this prints the exact output of ls /var/ on my machine. I'm going to incorporate this now that I have it into my code for this PR since I now realize my previous attempt was not even close to successful.

chuggafan avatar Jan 31 '25 03:01 chuggafan

:smile:

LADSoft avatar Feb 02 '25 14:02 LADSoft

Minor update: I've integrated the aforementioned code, current status is that it is able to run once, before getting a return of "EBADF" on the 2nd run, I have no idea what is causing it, and I've dug as far as the linux kernel clone3 syscall itself, as I'm getting EBADF off of the posix_spawn call, and not the adddup2 call, I have literally no idea what's going on there. I likely will want an actual linux box for future testing on this as this is... weird, and possibly has some weird WSL custom kernel shenanigans at play instead of the mainline kernel here, and I may shop around for some extra hardware to make that happen in the near future. But this is a basic status update.

chuggafan avatar Feb 07 '25 04:02 chuggafan

Well... I got back to this. I think I found my answer to this weird question by running omake on the OrangeC repo:

Failed to spawn, errno: 2, err: No such file or directory, command: .\omake\omake.exe -f \home\user\OrangeC\src\treetop.mak createdirs
Failed to spawn, errno: 9, err: Bad file descriptor, command: .\omake\omake.exe -f \home\user\OrangeC\src\treetop.mak library
Failed to spawn, errno: 9, err: Bad file descriptor, command: .\omake\omake.exe -f \home\user\OrangeC\src\treetop.mak exefile

On unix systems, this should default to forward slashes, I'll have to search for that logic somewhere....

chuggafan avatar Feb 12 '25 04:02 chuggafan

        gcc -O3 -Wextra -Wall -pedantic -c -o test_spawn.o test_spawn.c

/bin/bash
-c
--
gcc -O3 -Wextra -Wall -pedantic -c -o test_spawn.o test_spawn.c
Env: .DEFAULT_GOAL=
Env: .FEATURES=second-expansion order-only target-specific
Env: .INCLUDE_DIRS=
Env: CURDIR=/home/user/test_spawn
Env: DISPLAY=:0
Env: HOME=/home/user
Env: HOSTTYPE=x86_64
Env: LANG=en_US.UTF-8
Env: LOGNAME=user
Env: LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=00:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.avif=01;35:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.webp=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:*~=00;90:*#=00;90:*.bak=00;90:*.old=00;90:*.orig=00;90:*.part=00;90:*.rej=00;90:*.swp=00;90:*.tmp=00;90:*.dpkg-dist=00;90:*.dpkg-old=00;90:*.ucf-dist=00;90:*.ucf-new=00;90:*.ucf-old=00;90:*.rpmnew=00;90:*.rpmorig=00;90:*.rpmsave=00;90:
Env: MAKE=/home/user/omake.exe
Env: MAKECMDGOALS=
Env: MAKEFLAGS= -j:1 --jobserver-auth=3,4 $(MAKEOVERRIDES)
Env: MAKEOVERRIDES=
Env: MAKE_LEVEL=0
Env: NAME=DESKTOP-blargh
Env: OLDPWD=/home/user/test
Env: PATH=/home/user/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib:/mnt/c/Program Files/WindowsApps/TheDebianProject.DebianGNULinux_1.18.0.0_x64__76v4gfsz19hv4:/mnt/c/Program Files/ImageMagick-7.1.1-Q16-HDRI:/mnt/c/Program Files/Common Files/Oracle/Java/javapath:/mnt/c/Program Files (x86)/Common Files/Oracle/Java/java8path:/mnt/c/Program Files (x86)/Common Files/Oracle/Java/javapath:/mnt/c/Program Files/Oculus/Support/oculus-runtime:/mnt/c/Program Files/Microsoft/jdk-11.0.13.8-hotspot/bin:/mnt/c/Program Files/Microsoft/jdk-17.0.1.12-hotspot/bin:/mnt/c/Windows/system32:/mnt/c/Windows:/mnt/c/Windows/System32/Wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0/:/mnt/c/Windows/System32/OpenSSH/:/mnt/c/Program Files/Microsoft SQL Server/150/Tools/Binn/:/mnt/c/Program Files/Microsoft SQL Server/Client SDK/ODBC/170/Tools/Binn/:/mnt/c/Program Files/dotnet/:/mnt/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/mnt/c/Program Files/MATLAB/R2022a/bin:/mnt/c/Program Files/LLVM/bin:/mnt/c/Program Files/Graphviz/bin:/mnt/c/Program Files/Git/cmd:/mnt/c/Program Files/Microchip/xc32/v4.35/bin:/mnt/c/Program Files/Microchip/xc16/v2.10/bin:/mnt/c/Program Files (x86)/Windows Kits/10/Windows Performance Toolkit/:/mnt/c/Program Files/PuTTY/:/mnt/c/Program Files/CMake/bin:/mnt/c/Program Files/NVIDIA Corporation/NVIDIA app/NvDLISR:/mnt/c/Program Files (x86)/Arm GNU Toolchain arm-none-eabi/12.2 rel1/bin:/mnt/c/Users/user/AppData/Local/Programs/Python/Python310/Scripts/:/mnt/c/Users/user/AppData/Local/Programs/Python/Python310/:/mnt/c/Users/user/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/user/AppData/Local/Programs/Microsoft VS Code/bin:/mnt/c/Users/user/.dotnet/tools
Env: PULSE_SERVER=unix:/mnt/wslg/PulseServer
Env: PWD=/home/user/test_spawn
Env: SHELL=/bin/bash
Env: SHLVL=1
Env: TERM=xterm-256color
Env: USER=user
Env: VPATH=
Env: WAYLAND_DISPLAY=wayland-0
Env: WSL2_GUI_APPS_ENABLED=1
Env: WSLENV=
Env: WSL_DISTRO_NAME=Debian
Env: WSL_INTEROP=/run/WSL/13_interop
Env: XDG_RUNTIME_DIR=/mnt/wslg/runtime-dir
Env: _=/home/user/omake.exe
cwd: /home/user/test_spawn
        gcc test_spawn.o -o test_spawn

/bin/bash
-c
--
gcc test_spawn.o -o test_spawn
Env: .DEFAULT_GOAL=
Env: .FEATURES=second-expansion order-only target-specific
Env: .INCLUDE_DIRS=
Env: CURDIR=/home/user/test_spawn
Env: DISPLAY=:0
Env: HOME=/home/user
Env: HOSTTYPE=x86_64
Env: LANG=en_US.UTF-8
Env: LOGNAME=user
Env: LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=00:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.avif=01;35:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.webp=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:*~=00;90:*#=00;90:*.bak=00;90:*.old=00;90:*.orig=00;90:*.part=00;90:*.rej=00;90:*.swp=00;90:*.tmp=00;90:*.dpkg-dist=00;90:*.dpkg-old=00;90:*.ucf-dist=00;90:*.ucf-new=00;90:*.ucf-old=00;90:*.rpmnew=00;90:*.rpmorig=00;90:*.rpmsave=00;90:
Env: MAKE=/home/user/omake.exe
Env: MAKECMDGOALS=
Env: MAKEFLAGS= -j:1 --jobserver-auth=3,4 $(MAKEOVERRIDES)
Env: MAKEOVERRIDES=
Env: MAKE_LEVEL=0
Env: NAME=DESKTOP-blargh
Env: OLDPWD=/home/user/test
Env: PATH=/home/user/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib:/mnt/c/Program Files/WindowsApps/TheDebianProject.DebianGNULinux_1.18.0.0_x64__76v4gfsz19hv4:/mnt/c/Program Files/ImageMagick-7.1.1-Q16-HDRI:/mnt/c/Program Files/Common Files/Oracle/Java/javapath:/mnt/c/Program Files (x86)/Common Files/Oracle/Java/java8path:/mnt/c/Program Files (x86)/Common Files/Oracle/Java/javapath:/mnt/c/Program Files/Oculus/Support/oculus-runtime:/mnt/c/Program Files/Microsoft/jdk-11.0.13.8-hotspot/bin:/mnt/c/Program Files/Microsoft/jdk-17.0.1.12-hotspot/bin:/mnt/c/Windows/system32:/mnt/c/Windows:/mnt/c/Windows/System32/Wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0/:/mnt/c/Windows/System32/OpenSSH/:/mnt/c/Program Files/Microsoft SQL Server/150/Tools/Binn/:/mnt/c/Program Files/Microsoft SQL Server/Client SDK/ODBC/170/Tools/Binn/:/mnt/c/Program Files/dotnet/:/mnt/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/mnt/c/Program Files/MATLAB/R2022a/bin:/mnt/c/Program Files/LLVM/bin:/mnt/c/Program Files/Graphviz/bin:/mnt/c/Program Files/Git/cmd:/mnt/c/Program Files/Microchip/xc32/v4.35/bin:/mnt/c/Program Files/Microchip/xc16/v2.10/bin:/mnt/c/Program Files (x86)/Windows Kits/10/Windows Performance Toolkit/:/mnt/c/Program Files/PuTTY/:/mnt/c/Program Files/CMake/bin:/mnt/c/Program Files/NVIDIA Corporation/NVIDIA app/NvDLISR:/mnt/c/Program Files (x86)/Arm GNU Toolchain arm-none-eabi/12.2 rel1/bin:/mnt/c/Users/user/AppData/Local/Programs/Python/Python310/Scripts/:/mnt/c/Users/user/AppData/Local/Programs/Python/Python310/:/mnt/c/Users/user/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/user/AppData/Local/Programs/Microsoft VS Code/bin:/mnt/c/Users/user/.dotnet/tools
Env: PULSE_SERVER=unix:/mnt/wslg/PulseServer
Env: PWD=/home/user/test_spawn
Env: SHELL=/bin/bash
Env: SHLVL=1
Env: TERM=xterm-256color
Env: USER=user
Env: VPATH=
Env: WAYLAND_DISPLAY=wayland-0
Env: WSL2_GUI_APPS_ENABLED=1
Env: WSLENV=
Env: WSL_DISTRO_NAME=Debian
Env: WSL_INTEROP=/run/WSL/13_interop
Env: XDG_RUNTIME_DIR=/mnt/wslg/runtime-dir
Env: _=/home/user/omake.exe
cwd: /home/user/test_spawn
Failed to spawn, errno: 9, err: Bad file descriptor, command: gcc test_spawn.o -o test_spawn
cwd:/home/user/test_spawn

Error Makefile(9): commands returned error code -1

I've been staring at this result through WSL and I have absolutely no idea what in the universe is causing omake to only run the first time, not the 2nd. Utterly confusing, errno 9 (EBADF) as best as I can tell doesn't even come out in the most recent kernels! (I haven't looked at the Microsoft WSL kernel yet).

chuggafan avatar Feb 22 '25 22:02 chuggafan

so i don't know anything about linux, but, is there some possibility that the first run doesn't clean something up? Maybe Leaves a handle to the file being spawned open or something?

LADSoft avatar Feb 23 '25 03:02 LADSoft

Hmmm, re-looking with more info this might be an artifact of posix_spawn_file_actions_addclose only performing a fnctl call in posix_spawn and that kicks an EBADF?

chuggafan avatar Feb 23 '25 04:02 chuggafan

I figured it out, I forgot to actually fill in the pipe by calling pipe, so when I attempt to open a new pipe it fails the 2nd go around. I have no idea how it functions properly the first time.

chuggafan avatar Feb 23 '25 04:02 chuggafan

Current status with the new build: The current make program does not handle Makefile and makefile simultaneously, as linux is case sensitive, I would prefer a fallback system of something like Makefile -> makefile for automatic makefiles, but I'd have to do a bunch of piping reworks to fix that I think. My test program functions fine, but no major makefile has been checked yet.

chuggafan avatar Feb 26 '25 04:02 chuggafan

You know, if you want to put the updated omake to some serious test, there's #168 for that ;-)

GitMensch avatar Feb 26 '25 09:02 GitMensch

I'll put it on my list for later this week, to recheck the operation under windows.... then maybe we can roll it into master...

LADSoft avatar Mar 02 '25 07:03 LADSoft

I'm actually still working on a few issues with omake running on the OrangeC repo, notably, if I try to run it, it will try calling /homeuseromake.exe if I place omake.exe in the ~ (aka: /home/user) directory, so I'm doing some debugging to figure out where that is coming from, I'll say this PR is ready when omake can be used to compile OrangeC on linux, I've only done the bare minimum start here.

chuggafan avatar Mar 02 '25 13:03 chuggafan

What about just setting it to a "draft" until you considered this goal to be reached?

GitMensch avatar Mar 02 '25 14:03 GitMensch

Well, since I'm not the repository owner, and this was changed from draft by the repo owner, I can't exactly do that anymore, thanks github.

chuggafan avatar Mar 02 '25 17:03 chuggafan

yeah sorry about that. I pressed a button that did nothing like what I was expecting it to do... sigh....

LADSoft avatar Mar 03 '25 16:03 LADSoft

Ah, I've figured out why it's running the way it does, on Linux systems oftentimes /bin/sh is a symlink to another shell found in the system. I have to basically figure out if the shell is a unix shell or windows shell (and probably implement a preference on one or the other depending on if we're compiled for windows or linux) and then figure that out from there. https://www.gnu.org/software/make/manual/html_node/Choosing-the-Shell.html this specific document will be my gospel for gnu make compat. Perhaps I'm just going to check if $SHELL exists in the environment, if it does, we use $SHELL, otherwise we do what we've always done. (TL;DR: NormalizeFileName is being run on Linux atm if your default shell is /bin/bash, need a more generic solution than checking for /bin/sh)

chuggafan avatar Mar 04 '25 13:03 chuggafan

Ok, so there's STILL an issue with make on linux: jobserver passing, the long-option switch that we have breaks because the pipe numbers are passed with a comma separartor.

This jobserver implementation was tested a long time ago and almost certainly requires re-testing, but I will not touch the command line parsing since that's... a bit fragile for my tastes.

chuggafan avatar Mar 06 '25 00:03 chuggafan

Once I finish cleanup of #810 I'm going to return to work here, I think I can pretty decisively make some progress overall since I think 99% of the error right now is just "Get the switch-parser to parse stuff with commas" and that should unlock the "You have forgotten errors with Linux pipes" issue... At least that I tested (once).... We'll see how far I get with this in the next month, but I don't expect this to be wrapped up for the next release.

chuggafan avatar Apr 12 '25 19:04 chuggafan

I've gotten a bit further, I'm doing ~/omake -v -DCOMPILER=gcc-linux -f makefile on a linux VM and it's now exiting with error code 3 after I got --jobserver-auth= somewhat working.

chuggafan avatar May 01 '25 01:05 chuggafan

I figured out I missed out on namedpipes being available as a option in the POSIX jobserver... I'm going to add that as well... I still have no idea why the exit 3 is a thing, it only happens on the recursive make invocations and I don't see any indications coming out of some debug prints I added... https://www.gnu.org/software/make/manual/html_node/POSIX-Jobserver.html

chuggafan avatar May 02 '25 02:05 chuggafan

on the recursive make thing, what are you building OMAKE with? Because I suppose if it is occ you could still be hitting library issues.... if not I'm very curious as I've been assuming it was an OCC compile issue? If it isn't occ that changes a lot, especially since anything thrown by the C++ runtime SHOULD be caught in main now and you should get some sort of simple diagnostic...

LADSoft avatar May 02 '25 19:05 LADSoft

No, this is on linux after being compiled with COMPILER=gcc-linux, I'm not up-to-date on my code right now.

chuggafan avatar May 02 '25 22:05 chuggafan

so that means the GCC runtime is aborting for some reason, and it isn't because of a C++ runtime error because those should be caught. That sounds like a fun one to track down...

LADSoft avatar May 02 '25 23:05 LADSoft

It's extra fun because it's not the main omake process, but the subprocesses (so I have to somehow make the sub-make commands pause on gdb). And I'm not getting ANY print statements in the area I thought this would be in (the jobserver), so this is going to be a fun one.

chuggafan avatar May 02 '25 23:05 chuggafan

well gdb probably has something. Even microsoft saw the wisdom of this although they don't make it easy to do...

hmmm I just thought to wonder, do exceptions on threads even bubble up to main? Or do we need exception handling on each thread?

LADSoft avatar May 03 '25 03:05 LADSoft

Current status: I'm adding the fifo based system GNU make will use for communication (basically just a tempfile acting as a queue). Once that's done, I'm going to be adding verbose as an option, alongside multiple verbosity levels. One verbosity level (I think I'll make it verbosity level 5) will just be "Instrumentation everywhere" and then I'll deal with that somehow. That way the debugging messages don't have to be added and stripped and added and stripped, we can just get "What is the make system doing?" at an appropriate level for whatever investigation we need.

chuggafan avatar May 06 '25 02:05 chuggafan

so that sounds good. I don't know if you caught but in the other tools we use -y for verbosity.... adding more y characters increases the verbosity level. so for example -yyyyy is verbosity level 5..... I think it more standare to use -v but -v was being used for version info....

LADSoft avatar May 07 '25 02:05 LADSoft

I can make our verbosity level -y, I'd be using the CmdSwitch infrastructure to do it for sure however. Maybe something like -y with a default verbosity level of 0 (when not active), a -y default of 1, and you can set it to a larger number if need be? I'm not too familiar with the CLI parsing section, but that's something I think is doable...

Right now it's implemented as a CmdSwitchBool similar to how it's done in olink. I'll think it over, but I also will likely add a helper class to do "logging" where certain messages are only printed at specific logging levels (aka verbosities).

chuggafan avatar May 07 '25 02:05 chuggafan

Why not using -V for version information and use the standard -vvv then?

GitMensch avatar May 07 '25 05:05 GitMensch

@Chuggafan the compiler uses 'CmdSwitchString' for the /y switch then counts the number of y characters in the string and probably adds 1...

@GitMensch the reason i didn't do it was backwards compatibility... a lot of things use the -v switch right now. In particular I'm not sure if the cmake scripts use them (they have some way of getting version info but i don't remember what). And I'm not sure if other people are using it either...

LADSoft avatar May 08 '25 04:05 LADSoft