• Dear Cerberus X User!

    As we prepare to transition the forum ownership from Mike to Phil (TripleHead GmbH), we need your explicit consent to transfer your user data in accordance with our amended Terms and Rules in order to be compliant with data protection laws.

    Important: If you accept the amended Terms and Rules, you agree to the transfer of your user data to the future forum owner!

    Please read the new Terms and Rules below, check the box to agree, and click "Accept" to continue enjoying your Cerberus X Forum experience. The deadline for consent is April 5, 2024.

    Do not accept the amended Terms and Rules if you do not wish your personal data to be transferred to the future forum owner!

    Accepting ensures:

    - Continued access to your account with a short break for the actual transfer.

    - Retention of your data under the same terms.

    Without consent:

    - You don't have further access to your forum user account.

    - Your account and personal data will be deleted after April 5, 2024.

    - Public posts remain, but usernames indicating real identity will be anonymized. If you disagree with a fictitious name you have the option to contact us so we can find a name that is acceptable to you.

    We hope to keep you in our community and see you on the forum soon!

    All the best

    Your Cerberus X Team

Cerberus V2020-05-01 Debug works, Release not works.

Any hints what to look for with the results from ldd?

They are both 64 bit Linux.
 
On Arch Linux based systems, the package will already be installed.
 
Right I finally found an OS that throws the memory access violation.
I need to know the exact version of GCC being used, so type:
g++ --version
 
I suspect that this is the same issue that was occurring with MinGW 9.2 when optimisation are being applied.
 
It's g++ version 9.3.0-1
 
Changing gcc g++ version seams to be not that easy.
 
Well definitely looks like there is an optimisation bug in GCC-9.x.x. But yet some how Fedora 32, which uses a cutting edge GCC-10 hasn't got an issue with it.

Changing gcc g++ version seams to be not that easy.
Installing it is easy on Manjaro. Just look in the community repositories. But looks I will have to do some changes so that GCC version can be passed. Which means another update to the builders for transcc.

I'll have to do some more testing to make sure that GCC-8 hasn't got a problem with it.
 
OK Looks like it will work.

First install a lower version of GCC.
For Manjaro you will find these in the Add/Remove software under the Community repositories.

You will need to modify a number of files.
Code:
Import builder

Class GlfwBuilder Extends Builder

    Method New( tcc:TransCC )
        Super.New( tcc )
    End
    
    Method Config:String()
        Local config:=New StringStack
        For Local kv:=Eachin GetConfigVars()
            config.Push "#define CFG_"+kv.Key+" "+kv.Value
        Next
        Return config.Join( "~n" )
    End
    
    '***** GCC *****
    Method MakeGcc:Void()
    
        Local msize:=GetConfigVar( "GLFW_GCC_MSIZE_"+HostOS.ToUpper() )
        
        Local tconfig:=casedConfig+msize
    
        Local dst:="gcc_"+HostOS
        
        CreateDir dst+"/"+tconfig
        CreateDir dst+"/"+tconfig+"/internal"
        CreateDir dst+"/"+tconfig+"/external"
        
        CreateDataDir dst+"/"+tconfig+"/data"

        ' need to rewrite resources.rc so that icon is rebuilt
        CopyIcon(GetConfigVar( "GLFW_APP_ICON"),CurrentDir()+"\cerberus.ico")
        
        Local main:=LoadString( "main.cpp" )
        
        main=ReplaceBlock( main,"TRANSCODE",transCode )
        main=ReplaceBlock( main,"CONFIG",Config() )
        
        SaveString main,"main.cpp"
        
        If tcc.opt_build

            ChangeDir dst
            CreateDir "build"
            CreateDir "build/"+tconfig
            
            Local ccopts:="",ldopts:="", libopts:="", libcopy:=""

            If msize ccopts+=" -m"+msize;ldopts+=" -m"+msize

            ccopts+=" "+GetConfigVar( "GLFW_GCC_CC_OPTS" ).Replace( ";"," " )
            ldopts+=" "+GetConfigVar( "GLFW_GCC_LD_OPTS" ).Replace( ";"," " )
            libopts+=" "+GetConfigVar( "GLFW_GCC_LIB_OPTS" ).Replace( ";"," " )

            Select ENV_CONFIG
            Case "debug"
                ccopts+=" -O0"
            Case "release"
                ccopts+=" -O3 -DNDEBUG"
                ldopts+=" -s"
            End

            ' Process external libs to copy over
            ProcessExternalLibs( CurrentDir()+"\"+casedConfig, msize, libopts )

            Local cmd:="make", gccVer$=GetConfigVar( "GCC_VERSION_LINUX" ), GCCVER:="GCCVER="
            If HostOS="winnt" And FileType( tcc.MINGW_PATH+"/bin/mingw32-make.exe" ) cmd="mingw32-make"
            
            ' Set up additional operating specific values.
            If HostOS="winnt"
                ldopts+=" -L"+tcc._libs+"Win"+msize
            Else If HostOS="linux"
                If gccVer<>"" GCCVER+="-"+gccVer
            Endif

            Execute cmd+" "+GCCVER+" CCOPTS=~q"+ccopts+"~q LDOPTS=~q"+ldopts+"~q LIBOPTS=~q"+libopts+"~q OUT=~q"+tconfig+"/CerberusGame~q"

            If tcc.opt_run

                ChangeDir tconfig

                If HostOS="winnt"
                    Execute "CerberusGame"
                Else
                    Execute "./CerberusGame"
                Endif
            Endif
        Endif
            
    End
    
    '***** Vc2010 *****
    Method MakeVc2010:Void()
    
        CreateDir "vc2010/"+casedConfig
        CreateDir "vc2010/"+casedConfig+"/internal"
        CreateDir "vc2010/"+casedConfig+"/external"
        
        CreateDataDir "vc2010/"+casedConfig+"/data"
        
        Local main:=LoadString( "main.cpp" )
        
        main=ReplaceBlock( main,"TRANSCODE",transCode )
        main=ReplaceBlock( main,"CONFIG",Config() )
        
        SaveString main,"main.cpp"
        
        If tcc.opt_build

            ChangeDir "vc2010"

            Execute "~q"+tcc.MSBUILD_PATH+"~q /p:Configuration="+casedConfig+" /p:Platform=Win32 CerberusGame.sln"
            
            If tcc.opt_run
            
                ChangeDir casedConfig

                Execute "CerberusGame"
                
            Endif
        Endif
    End

    '***** Msvc *****
    Method MakeMsvc:Void()
    
        CreateDir "msvc/"+casedConfig
        CreateDir "msvc/"+casedConfig+"/internal"
        CreateDir "msvc/"+casedConfig+"/external"
        
        CreateDataDir "msvc/"+casedConfig+"/data"
        
        ' need to rewrite resources.rc so that icon is rebuilt
        CopyIcon(GetConfigVar( "GLFW_APP_ICON"),CurrentDir()+"\cerberus.ico")
        
        Local main:=LoadString( "main.cpp" )
        
        main=ReplaceBlock( main,"TRANSCODE",transCode )
        main=ReplaceBlock( main,"CONFIG",Config() )
        
        SaveString main,"main.cpp"
        
        If tcc.opt_build

            ChangeDir "msvc"

            Execute "~q"+tcc.MSBUILD_PATH+"~q /p:Configuration="+casedConfig'+" /p:Platform=win32 CerberusGame.sln"
            
            If tcc.opt_run
            
                ChangeDir casedConfig

                Execute "CerberusGame"
                
            Endif
        Endif
    End

    '***** Xcode *****   
    Method MakeXcode:Void()

        CreateDataDir "xcode/data"

        Local main:=LoadString( "main.cpp" )
        
        main=ReplaceBlock( main,"TRANSCODE",transCode )
        main=ReplaceBlock( main,"CONFIG",Config() )
        
        SaveString main,"main.cpp"
        
        If tcc.opt_build
        
            ChangeDir "xcode"
            
'            Execute "set -o pipefail && xcodebuild -configuration "+casedConfig+" | egrep -A 5 ~q(error|warning):~q"
            Execute "xcodebuild -configuration "+casedConfig
            
            If tcc.opt_run
            
                ChangeDir "build/"+casedConfig
                ChangeDir "CerberusGame.app/Contents/MacOS"
                
                Execute "./CerberusGame"
            Endif
        Endif
    End
    
    '***** Builder *****   
    Method IsValid:Bool()
        Select HostOS
        Case "winnt"
            If tcc.MINGW_PATH Or tcc.MSBUILD_PATH Return True
        Default
            Return True
        End
        Return False
    End
    
    Method Begin:Void()
        ENV_LANG="cpp"
        _trans=New CppTranslator
    End
    
    Method MakeTarget:Void()
        Select HostOS
        Case "winnt"
            If GetConfigVar( "GLFW_USE_MINGW" )="1" And tcc.MINGW_PATH
                MakeGcc
            Else If FileType( "vc2010" )=FILETYPE_DIR
                MakeVc2010
            Else If FileType( "msvc" )=FILETYPE_DIR
                MakeMsvc
            Else If tcc.MINGW_PATH
                MakeGcc
            Endif
        Case "macos"
            MakeXcode
        Case "linux"
            MakeGcc
        End
    End

    ' Process external shared libraries    to copy
    Method ProcessExternalLibs( config:String, arch:String, link:String )
        Local libStr:String = GetConfigVar( "GLFW_COPY_LIBS" ).ToLower()
        If libStr = "" Then Return

        Local libcopy:String[] = libStr.Split( ";" )
        Local dst:String = config+arch

        For Local i:= Eachin libcopy
            If HostOS="winnt"
                If i <> ""
                    If FileType( dst+"/"+i+".dll" ) = FILETYPE_FILE Continue

                    If CopyFile( tcc._libs+"Win"+arch+"/"+i+".dll", dst+"/"+i+".dll" ) = 1
                        Print "Copied "+i+".dll to "+dst
                    Else
                        Print "Failed to copy "+i+" to "+dst
                    EndIf

                    If FileType( tcc._libs+"/"+i+"_COPYING" )<> FILETYPE_NONE
                        If CopyFile( tcc._libs+"/"+i+"_COPYING", dst+"/"+i+"_COPYING" ) = 1
                            Print "Copied "+i+"_COPYING to "+dst
                        Else
                            Print "Failed to copy "+i+"_COPYING To "+dst
                        Endif
                    Endif

                    If FileType( tcc._libs+"/"+i+"_LICENCE" )<> FILETYPE_NONE
                        If CopyFile( tcc._libs+"/"+i+"_LICENCE", dst+"/"+i+"_LICENCE" ) = 1
                            Print "Copied "+i+"_LICENCE to "+dst
                        Else
                            Print "Failed to copy "+i+"_COPYING To "+dst
                        Endif
                    Endif
                Endif
            EndIf
        Next
    End
End
Code:
Import builder

Class StdcppBuilder Extends Builder

    Method New( tcc:TransCC )
        Super.New( tcc )
    End

    Method Config:String()
        Local config:=New StringStack
        For Local kv:=Eachin GetConfigVars()
            config.Push "#define CFG_"+kv.Key+" "+kv.Value
        Next
        Return config.Join( "~n" )
    End
    
    Method IsValid:Bool()
        Select HostOS
        Case "winnt"
            If tcc.MINGW_PATH Return True
        Default
            Return True
        End
        Return False
    End

    Method Begin:Void()
        ENV_LANG="cpp"
        _trans=New CppTranslator
    End
    
    Method MakeTarget:Void()
    
        Select ENV_CONFIG
        Case "debug" SetConfigVar "DEBUG","1"
        Case "release" SetConfigVar "RELEASE","1"
        Case "profile" SetConfigVar "PROFILE","1"
        End
        
        CopySourceFiles(".")
        
        Local main:=LoadString( "main.cpp" )

        main=ReplaceBlock( main,"TRANSCODE",transCode )
        main=ReplaceBlock( main,"CONFIG",Config() )

        SaveString main,"main.cpp"
        
        If tcc.opt_build

            Local out:="main_"+HostOS
            DeleteFile out
            
            Local OPTS:="",LIBS:="", GCCVER:="", gccVer:=GetConfigVar( "GCC_VERSION_LINUX" )
            
            Select ENV_HOST
            Case "winnt"
                OPTS+=" -Wno-free-nonheap-object"
                LIBS+=" -lwinmm -lws2_32"
            Case "macos"
                OPTS+=" -Wno-parentheses -Wno-dangling-else"
                OPTS+=" -mmacosx-version-min=10.9 -std=gnu++0x -stdlib=libc++"
            Case "linux"
                OPTS+=" -Wno-unused-result"
                LIBS+=" -lpthread"
                If gccVer<>"" GCCVER="-"+gccVer
            End
            
            Select ENV_CONFIG
            Case "debug"
                OPTS+=" -O0"
            Case "release"
                OPTS+=" -O3 -DNDEBUG"
            End
            
            Local cc_opts:=GetConfigVar( "CC_OPTS" )
            If cc_opts OPTS+=" "+cc_opts.Replace( ";"," " )
            
            Local cc_libs:=GetConfigVar( "CC_LIBS" )
            If cc_libs LIBS+=" "+cc_libs.Replace( ";"," " )
            
      If HostOS="macos"
        Execute "clang++"+OPTS+" -o "+out+" main.cpp"+LIBS
      Else
        Execute "g++"+GCCVER+" "+OPTS+" -o "+out+" main.cpp"+LIBS
      Endif
            
            If tcc.opt_run
                Execute "~q"+RealPath( out )+"~q"
            Endif
        Endif
    End
    
End
And in the glfw3 gcc_linux make file
the first part needs to be:
Makefile:
CC=gcc$(GCCVER)
CFLAGS=

CXX=g++$(GCCVER)
CXXFLAGS=
Now for the tricky bit.
After making the changes, compile trancc.cxs. Then make a backup of transcc.build and then rename the transcc.buildV2020 to transcc.build.
Open a command line terminal and change directory to cerberus/src and type.
g++-8 -O3 -DNDEBUG -o ../bin/transcc_linux transcc/transcc.build/cpptool/main.cpp -lpthread

All you do then is add #GCC_VERSION="8" to your source file for that version of GCC to call.
 
This works!!! Thank you very much! I had to do it twice, because I had the linux binary installed not the latest dev branch on git hub.
Luckily Manjaro has Qt 5 already installed. I wouldn't have had the energie to wait for this to happen...

All you do then is add #GCC_VERSION="8" to your source file
That was the only thing I had to investigate myself. You named it #GCC_VERSION_LINUX in the code.

BTW If we keep something like this for the official release it might be better to use the naming scheme of config settings like #GLFW_GCC_MSIZE_WINNT
So it would be for the version: #GLFW_GCC_VERSION_LINUX
And put it into the config.cxs file to avoid the need of having it in each source file.
 
Last edited:
BTW If we keep something like this for the official release it might be better to use the naming scheme of config settings like #GLFW_GCC_MSIZE_WINNT
So it would be for the version: #GLFW_GCC_VERSION_LINUX
I've never been a fan of the GLFW naming when needing to pass compiler specific information to the compiler.
It can confuse the situation when you have multiple preprocessor directives that basically do the same thing.
If you need to do something like that then use preprocessor conditionals with one of the constants TARGET, CONFIG, HOST, etc.
And put it into the config.cxs file to avoid the need of having it in each source file.
Not a good idea. Not everyone will be using the same compiler and you only need to put it in the main build file, or place it in your own config.cxs within your project directory.
 
Well after a little bit of a think and a browse of the GCC options. I've found that passing the option -fpic works.
So all you need to add is:
#GLFW_GCC_CC_OPTS+="-fpic -no-pie"
So no need to change any files yet.
 
I've never been a fan of the GLFW naming when needing to pass compiler specific information to the compiler.
It can confuse the situation when you have multiple preprocessor directives that basically do the same thing.
Technically this is right, but there are two practical reasons to name like this:
1. Consistency with the existing stuff. If there is a better scheme it should be changed for all consts.
2. User perspective, esp. for beginners. If you know the target you are heading for, you know which config settings are of importance without any background knowledge.

Putting #GLFW_GCC_VERSION_LINUX into config.cxs
Not a good idea. Not everyone will be using the same compiler and you only need to put it in the main build file, or place it in your own config.cxs within your project directory.
I was not thinking about setting it to 8 but leaving it empty to be aware of the existence of this Option. Further more if you are on a system with this problem, you need this setting for building your app every time.

#GLFW_GCC_CC_OPTS+="-fpic -no-pie"
So no need to change any files yet.
Nice you found another way to deal with the problem.
 
@zuibaf :
You will have to build from source. But you will need to change a few things.
Open the rebuildall.sh file and add -fpic to the g++ command.
Open the config.cxs files in the templates and add the necessary #GLFW_GCC_OPTS.
You can then run the rebuildall.script.
 
I did the procedure you indicated didn't work, so I was looking at the exit inside Ted and the '-fpic' selectors never appeared.

After 11 attempts, I think I can solve it:

So in the 'glfw.cxs' file, it looks like GetConfigVar is not getting the value correctly from the GLFW_GCC_CC_OPTS variable,
I put a sentence "Print ccopts" and it appears empty.
ccopts+=" "+GetConfigVar( "GLFW_GCC_CC_OPTS" ).Replace( ";"," " ) ldopts+=" "+GetConfigVar( "GLFW_GCC_LD_OPTS" ).Replace( ";"," " ) libopts+=" "+GetConfigVar( "GLFW_GCC_LIB_OPTS" ).Replace( ";"," " ) Print "ccopts=" + ccopts ' I inserted the line for test. Select ENV_CONFIG Case "debug" ccopts+=" -O0" Case "release" ccopts+=" -O3 -DNDEBUG" ldopts+=" -s" End
To work what I did was to include "-fpic" directly here, on line:
Code:
ccopts+=" "+GetConfigVar( "GLFW_GCC_CC_OPTS" ).Replace( ";"," " )
ldopts+=" "+GetConfigVar( "GLFW_GCC_LD_OPTS" ).Replace( ";"," " )
libopts+=" "+GetConfigVar( "GLFW_GCC_LIB_OPTS" ).Replace( ";"," " )

Print "ccopts=" + ccopts    ' I inserted the line for test.

Select ENV_CONFIG
Case "debug"
    ccopts+=" -O0"
Case "release"
    ccopts+=" -O3 -DNDEBUG -fpic"      ' <================ Here, it works.
    ldopts+=" -s"
End
[/ICODE]
I'm still using g ++ (GCC) 9.3.1 20200408 (Red Hat 9.3.1-2)
 
Try passing the options through #GLFW_GCC_LD_OPTS instead of #GLFW_GCC_CC_OPTS and see what happens.
 
I think I understand, after changing the inclusion of flags in the config.cxs file: #GLFW_GCC_CC_OPTS + = "- fpic".
And after recompiling transcc, if I try to compile the program example, in this case, "blobmaster", if there is already a build directory, it looks like transcc, reuses some files, instead of deleting everything and copying the new updated files.
Then, only after deleting the build folder, does the flag: "#GLFW_GCC_CC_OPTS + =" - fpic "appear.
I don't know if this is a bug or if it is the behavior of transcc.
 
As I understand it, every time I recompile transcc, I need to go, for example, in the 'examples' folder, and delete the build folder for each one, so that transcc copies the updated files when I try to build in release mode .
Now, I will even test it, I will rebuild transcc again, this time removing the flag: #GLFW_GCC_CC_OPTS + = "- fpic and I will not delete the build folder one of the examples I am testing, and the program will work correctly, because transcc did not copy nothing because the files already exist.
I will test here, if my hypothesis is correct this will occur.
 
You have to delete old builds when downloading a new version, or making changes to the templates.
 
Back
Top Bottom