9fans / plan9port

Plan 9 from User Space
https://9fans.github.io/plan9port/
Other
1.63k stars 321 forks source link

can not build under gcc-less linux #640

Open z-erica opened 8 months ago

z-erica commented 8 months ago

https://github.com/9fans/plan9port/blob/be7c68f6954f7dcaa53403e0f600716f65a13d32/bin/9c#L115-L122

some linux distributions (e.g. chimera linux) use clang as a default toolchain. this means 9c can't be used as is

JamesParrott commented 8 months ago

What happens when clang is used to compile plan 9 instead?

z-erica commented 8 months ago

i believe it works fine; the main issue is that i had to patch this file for anything to run in the first place

JamesParrott commented 8 months ago

Great. I see the problem now. The Linux branch only checks CC9 against tcc. There's plenty of code there to support clang on other platforms already. As you know it already works, are you allowed to share, or even contribute your patch?

Otherwise, if something else is already setting CC9 to clang, and if useclang works on Linux just as well as on BSDs, would something like the new code below suffice, to treat Linux clang the same as Dragon clang and BSD clang?

case "$tag" in
*DragonFly*gcc*|*BSD*gcc*)  usegcc ;;
*DragonFly*clang|*BSD*clang*|*Linux*clang*) useclang ;;
*Darwin*)
        useclang
        cflags="$cflags -g3 -m64"
        ;;
*HP-UX*)    cc=${CC9:-cc}; cflags="-g -O -c -Ae" ;;
*Linux*)    usegcc
        case "${CC9:-gcc}" in
        tcc)
            cc=tcc
            cflags="-c -g"
            ;;
        esac
        ;;
z-erica commented 8 months ago

it should suffice, yes!