Please do not post a support request without first reading and following the advice in https://retropie.org.uk/forum/topic/3/read-this-first

Compiles fine manually, fails to compile in RetroPie script



  • Hi, I'm currently attempting to write a port for xash3d-fwgs, a newer version of the engine for Half-Life. Unfortunately, I'm having a strange issue where running the steps manually results in a compiled build that functions, but running them through a RetroPie scriptmodule fails. I suspect that what is going on is RetroPie is adding its own CFLAGS and this is causing the script's detection to fail. Here's the in-progress version of the script module:

    rp_module_id="xash3d-fwgs"
    rp_module_desc="xash3d-fwgs - Half-Life Engine Port"
    rp_module_help="Please add your full version xash3d-fwgs files to $romdir/ports/$md_id/ to play."
    rp_module_section="exp"
    rp_module_flags="!mali !x86"
    
    function depends_xash3d-fwgs() {
        getDepends libsdl2-dev libfontconfig1-dev libfreetype6-dev
    }
    
    function sources_xash3d-fwgs() {
        gitPullOrClone "$md_build" https://github.com/FWGS/xash3d-fwgs.git
    }
    
    function build_xash3d-fwgs() {
         ./waf configure -T release
         ./waf build
        md_ret_require=(
            "$md_build/build/game_launch/xash3d"
            "$md_build/build/engine/libxash.so"
        )
    }
    
    function install_xash3d-fwgs() {
        ./waf install
    }
    
    function configure_xash3d-fwgs() {
    # Work not started on configure, ignore.
    }
    

    Building with this script results in the following:

    [  3/258] Compiling public/xash3d_mathlib.c
    [  4/258] Compiling public/crtlib.c
    In file included from ../public/crtlib.h:20,
                     from ../public/crclib.c:17:
    ../public/build.h:188:4: error: #error "Unknown ARM"
       #error "Unknown ARM"
    

    Instructions for building manually found here under Building: https://github.com/FWGS/xash3d-fwgs

    Looking into build/compile_commands.json in my manual compile, I see the following:

     "arguments": [
          "/usr/bin/gcc",
          "-g",
          "-fvisibility=hidden",
          "-O3",
          "-fdiagnostics-color=always",
          "-Werror=return-type",
          "-Werror=parentheses",
          "-Werror=vla",
           ...
    

    Looking at the build/compile_commands.json of the RetroPie build, I see the following:

      {
        "arguments": [
          "/usr/bin/gcc",
          "-march=armv8-a+crc",
          "-mtune=cortex-a72",
          "-mfpu=neon-fp-armv8",
          "-mfloat-abi=hard",
          "-O2",
          "-g",
          "-fvisibility=hidden",
          "-O3",
          "-fdiagnostics-color=always",
          "-Werror=return-type",
          "-Werror=parentheses",
          "-Werror=vla",
          ...
    

    Looking at the piece of code for figuring out the ARM stuff, from public/build.h:

    #elif defined __arm__ || defined _M_ARM
            #if defined _M_ARM
                    // msvc can only armv7 ?
                    #define XASH_ARM 7
            #elif __ARM_ARCH == 7 || __ARM_ARCH_7__
                    #define XASH_ARM 7
            #elif __ARM_ARCH == 6 || __ARM_ARCH_6__ || __ARM_ARCH_6J__
                    #define XASH_ARM 6
            #elif __ARM_ARCH == 5 || __ARM_ARCH_5__
                    #define XASH_ARM 5
            #elif __ARM_ARCH == 4 || __ARM_ARCH_4__
                    #define XASH_ARM 4
            #else
                    #error "Unknown ARM"
            #endif
    
            ...
    
            #if defined __SOFTFP__ || __ARM_PCS_VFP == 0
                    #define XASH_ARM_SOFTFP 1
            #else // __SOFTFP__
                    #define XASH_ARM_HARDFP 1
    
           ...
    #if XASH_ARM == 7
            #define XASH_ARMv7 1
    #elif XASH_ARM == 6
            #define XASH_ARMv6 1
    #elif XASH_ARM == 5
            #define XASH_ARMv5 1
    #elif XASH_ARM == 4
            #define XASH_ARMv4 1
    #endif
    

    I'm not too sure how to continue here. I attempted to add CFLAGS="" before the ./waf calls in build and it did indeed remove the flags that RetroPie seems to be adding however you can see that it's only worked for a few files, not all of them.

    Any ideas/advice would be most appreciated.


  • Global Moderator

    That's because -march=armv8-a+crc switches __ARM_ARCH to 8, while the defaults for the compiler sets __ARM_ARCH to 6. The header you referenced doesn't know about the newer __ARM_ARCH variant.

    # RetroPie flags
    $ echo | gcc -march=armv8-a+crc -dM -E - | grep -i '__ARM_ARCH '
    #define __ARM_ARCH 8
    
    # no flags
    $ echo | gcc -dM -E - | grep -i '__ARM_ARCH '
    #define __ARM_ARCH 6
    


  • @mitu Thank you, I've sent a pull request upstream with the fix.



  • @zerojay You pull was accepted





  • Hi
    I update extras script and test xash3d-fwgs
    Could not successfully build xash3d-fwgs - xash3d-fwgs - Half-Life Engine Port (home/pi/RetroPie-Setup/rmp/build/xash3d-fwgs/xash3d-fwgs/build/game_launch/Xash3D not found)...

    Really the folder is empty sftp://retropie/home/pi/RetroPie-Setup/tmp/build/xash3d-fwgs/xash3d-fwgs/build/game_launch/ empty

    If you need logs, please ask me



  • @kactius said in Compiles fine manually, fails to compile in RetroPie script:

    Hi
    I update extras script and test xash3d-fwgs
    Could not successfully build xash3d-fwgs - xash3d-fwgs - Half-Life Engine Port (home/pi/RetroPie-Setup/rmp/build/xash3d-fwgs/xash3d-fwgs/build/game_launch/Xash3D not found)...

    Really the folder is empty sftp://retropie/home/pi/RetroPie-Setup/tmp/build/xash3d-fwgs/xash3d-fwgs/build/game_launch/ empty

    If you need logs, please ask me

    Yeah, post the logs please.



  • @zerojay
    /home/pi/RetroPie-Setup/logs/rps_2020-10-14_123218.log.gz
    https://pastebin.com/wAh1AfQr

    If you need more logs, say me patch to other logs



  • @kactius said in Compiles fine manually, fails to compile in RetroPie script:

    @zerojay
    /home/pi/RetroPie-Setup/logs/rps_2020-10-14_123218.log.gz
    https://pastebin.com/wAh1AfQr

    If you need more logs, say me patch to other logs

    Nothing I can do about that, you'll need to ask upstream.



Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.

Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.