Getting segmentation fault when trying to compile:
$ cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_SHARED=ON -DDEPTH_CLIPPING=ON -DFLIP_VIEWPORT=ON ..
CMake Deprecation Warning at CMakeLists.txt:1 (CMAKE_MINIMUM_REQUIRED):
Compatibility with CMake < 2.8.12 will be removed from a future version of
CMake.
Update the VERSION argument <min> value or use a ...<max> suffix to tell
CMake that the project does not need compatibility with older versions.
-- The C compiler identification is GNU 10.2.0
-- The CXX compiler identification is GNU 10.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Mercurial (hg) repository not found. You can go on, but version info will be wrong.
CMake Warning (dev) at CMakeLists.txt:90 (GET_TARGET_PROPERTY):
Policy CMP0026 is not set: Disallow use of the LOCATION target property.
Run "cmake --help-policy CMP0026" for policy details. Use the cmake_policy
command to set the policy and suppress this warning.
The LOCATION property should not be read from target "lemon". Use the
target name directly with add_custom_command, or use the generator
expression $<TARGET_FILE>, as appropriate.
This warning is for project developers. Use -Wno-dev to suppress it.
-- Configuring done
-- Generating done
CMake Warning:
Manually-specified variables were not used by the project:
BUILD_SHARED
-- Build files have been written to: /mnt/data/gm/fna/src/MojoShader/build
$ make -j2
Scanning dependencies of target lemon
Scanning dependencies of target glcaps
[ 2%] Building C object CMakeFiles/lemon.dir/misc/lemon.c.o
[ 5%] Building C object CMakeFiles/glcaps.dir/utils/glcaps.c.o
[ 7%] Linking C executable glcaps
[ 7%] Built target glcaps
[ 10%] Linking C executable lemon
[ 10%] Built target lemon
[ 15%] Generating ../mojoshader_parser_hlsl.h
[ 15%] Generating ../mojoshader_lexer.c
make[2]: *** [CMakeFiles/mojoshader.dir/build.make:83: ../mojoshader_parser_hlsl.h] Segmentation fault
make[2]: *** Deleting file '../mojoshader_parser_hlsl.h'
make[1]: *** [CMakeFiles/Makefile2:329: CMakeFiles/mojoshader.dir/all] Error 2
make: *** [Makefile:103: all] Error 2
Let me know if I can provide any other info. Thanks.
Edit-
For some reason building debug version works:
$ cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED=ON -DDEPTH_CLIPPING=ON -DFLIP_VIEWPORT=ON ..
CMake Deprecation Warning at CMakeLists.txt:1 (CMAKE_MINIMUM_REQUIRED):
Compatibility with CMake < 2.8.12 will be removed from a future version of
CMake.
Update the VERSION argument <min> value or use a ...<max> suffix to tell
CMake that the project does not need compatibility with older versions.
-- The C compiler identification is GNU 10.2.0
-- The CXX compiler identification is GNU 10.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Mercurial (hg) repository not found. You can go on, but version info will be wrong.
CMake Warning (dev) at CMakeLists.txt:90 (GET_TARGET_PROPERTY):
Policy CMP0026 is not set: Disallow use of the LOCATION target property.
Run "cmake --help-policy CMP0026" for policy details. Use the cmake_policy
command to set the policy and suppress this warning.
The LOCATION property should not be read from target "lemon". Use the
target name directly with add_custom_command, or use the generator
expression $<TARGET_FILE>, as appropriate.
This warning is for project developers. Use -Wno-dev to suppress it.
-- Configuring done
-- Generating done
CMake Warning:
Manually-specified variables were not used by the project:
BUILD_SHARED
-- Build files have been written to: /mnt/data/gm/fna/src/MojoShader/build-new
$ make -j2
Scanning dependencies of target lemon
Scanning dependencies of target glcaps
[ 2%] Building C object CMakeFiles/glcaps.dir/utils/glcaps.c.o
[ 5%] Building C object CMakeFiles/lemon.dir/misc/lemon.c.o
[ 7%] Linking C executable glcaps
[ 7%] Built target glcaps
[ 10%] Linking C executable lemon
[ 10%] Built target lemon
[ 12%] Generating ../mojoshader_parser_hlsl.h
Scanning dependencies of target mojoshader
[ 17%] Building C object CMakeFiles/mojoshader.dir/mojoshader.c.o
[ 17%] Building C object CMakeFiles/mojoshader.dir/mojoshader_common.c.o
[ 20%] Building C object CMakeFiles/mojoshader.dir/mojoshader_opengl.c.o
[ 22%] Building C object CMakeFiles/mojoshader.dir/mojoshader_metal.c.o
[ 25%] Building C object CMakeFiles/mojoshader.dir/mojoshader_d3d11.c.o
[ 27%] Building C object CMakeFiles/mojoshader.dir/mojoshader_vulkan.c.o
[ 30%] Building C object CMakeFiles/mojoshader.dir/profiles/mojoshader_profile_arb1.c.o
[ 32%] Building C object CMakeFiles/mojoshader.dir/profiles/mojoshader_profile_bytecode.c.o
[ 35%] Building C object CMakeFiles/mojoshader.dir/profiles/mojoshader_profile_d3d.c.o
[ 37%] Building C object CMakeFiles/mojoshader.dir/profiles/mojoshader_profile_hlsl.c.o
/mnt/data/gm/fna/src/MojoShader/profiles/mojoshader_profile_hlsl.c: In function ‘emit_HLSL_const_array’:
/mnt/data/gm/fna/src/MojoShader/profiles/mojoshader_profile_hlsl.c:653:17: warning: unused variable ‘cstr’ [-Wunused-variable]
653 | const char *cstr = NULL;
| ^~~~
/mnt/data/gm/fna/src/MojoShader/profiles/mojoshader_profile_hlsl.c: In function ‘emit_HLSL_attribute’:
/mnt/data/gm/fna/src/MojoShader/profiles/mojoshader_profile_hlsl.c:788:17: warning: unused variable ‘usage_str’ [-Wunused-variable]
788 | const char *usage_str = NULL;
| ^~~~~~~~~
/mnt/data/gm/fna/src/MojoShader/profiles/mojoshader_profile_hlsl.c:932:66: warning: ‘%s’ directive output may be truncated writing up to 63 bytes into a region of size 16 [-Wformat-truncation=]
932 | sizeof(ctx->hlsl_outpos_name), "%s", var);
| ^~ ~~~
/mnt/data/gm/fna/src/MojoShader/profiles/mojoshader_profile_hlsl.c:931:25: note: ‘snprintf’ output between 1 and 64 bytes into a destination of size 16
931 | snprintf(ctx->hlsl_outpos_name,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
932 | sizeof(ctx->hlsl_outpos_name), "%s", var);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/mnt/data/gm/fna/src/MojoShader/profiles/mojoshader_profile_hlsl.c: In function ‘emit_HLSL_DP2ADD’:
/mnt/data/gm/fna/src/MojoShader/profiles/mojoshader_profile_hlsl.c:2131:57: warning: ‘%s’ directive output may be truncated writing up to 63 bytes into a region of size 61 [-Wformat-truncation=]
2131 | char extra[64]; snprintf(extra, sizeof (extra), " + %s", src2);
| ^~ ~~~~
/mnt/data/gm/fna/src/MojoShader/profiles/mojoshader_profile_hlsl.c:2131:21: note: ‘snprintf’ output between 4 and 67 bytes into a destination of size 64
2131 | char extra[64]; snprintf(extra, sizeof (extra), " + %s", src2);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[ 40%] Building C object CMakeFiles/mojoshader.dir/profiles/mojoshader_profile_glsl.c.o
[ 42%] Building C object CMakeFiles/mojoshader.dir/profiles/mojoshader_profile_metal.c.o
/mnt/data/gm/fna/src/MojoShader/profiles/mojoshader_profile_metal.c: In function ‘get_METAL_uniform_array_varname’:
/mnt/data/gm/fna/src/MojoShader/profiles/mojoshader_profile_metal.c:95:17: warning: unused variable ‘shadertype’ [-Wunused-variable]
95 | const char *shadertype = ctx->shader_type_str;
| ^~~~~~~~~~
/mnt/data/gm/fna/src/MojoShader/profiles/mojoshader_profile_metal.c: In function ‘emit_METAL_const_array’:
/mnt/data/gm/fna/src/MojoShader/profiles/mojoshader_profile_metal.c:675:17: warning: unused variable ‘cstr’ [-Wunused-variable]
675 | const char *cstr = NULL;
| ^~~~
/mnt/data/gm/fna/src/MojoShader/profiles/mojoshader_profile_metal.c: In function ‘emit_METAL_uniform’:
/mnt/data/gm/fna/src/MojoShader/profiles/mojoshader_profile_metal.c:717:17: warning: unused variable ‘utype’ [-Wunused-variable]
717 | const char *utype = get_METAL_uniform_type(ctx, regtype);
| ^~~~~
/mnt/data/gm/fna/src/MojoShader/profiles/mojoshader_profile_metal.c: In function ‘emit_METAL_attribute’:
/mnt/data/gm/fna/src/MojoShader/profiles/mojoshader_profile_metal.c:817:17: warning: unused variable ‘usage_str’ [-Wunused-variable]
817 | const char *usage_str = NULL;
| ^~~~~~~~~
/mnt/data/gm/fna/src/MojoShader/profiles/mojoshader_profile_metal.c: In function ‘metal_texld’:
/mnt/data/gm/fna/src/MojoShader/profiles/mojoshader_profile_metal.c:1725:21: warning: unused variable ‘funcname’ [-Wunused-variable]
1725 | const char *funcname = NULL;
| ^~~~~~~~
/mnt/data/gm/fna/src/MojoShader/profiles/mojoshader_profile_metal.c: In function ‘emit_METAL_DP2ADD’:
/mnt/data/gm/fna/src/MojoShader/profiles/mojoshader_profile_metal.c:2254:57: warning: ‘%s’ directive output may be truncated writing up to 63 bytes into a region of size 61 [-Wformat-truncation=]
2254 | char extra[64]; snprintf(extra, sizeof (extra), " + %s", src2);
| ^~ ~~~~
/mnt/data/gm/fna/src/MojoShader/profiles/mojoshader_profile_metal.c:2254:21: note: ‘snprintf’ output between 4 and 67 bytes into a destination of size 64
2254 | char extra[64]; snprintf(extra, sizeof (extra), " + %s", src2);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[ 45%] Building C object CMakeFiles/mojoshader.dir/profiles/mojoshader_profile_spirv.c.o
/mnt/data/gm/fna/src/MojoShader/profiles/mojoshader_profile_spirv.c: In function ‘spv_emit_vpos_vkmode’:
/mnt/data/gm/fna/src/MojoShader/profiles/mojoshader_profile_spirv.c:1617:12: warning: unused variable ‘id_vpos’ [-Wunused-variable]
1617 | uint32 id_vpos = spv_bumpid(ctx);
| ^~~~~~~
/mnt/data/gm/fna/src/MojoShader/profiles/mojoshader_profile_spirv.c: In function ‘emit_SPIRV_TEXLD’:
/mnt/data/gm/fna/src/MojoShader/profiles/mojoshader_profile_spirv.c:3560:23: warning: unused variable ‘texcoord_reg’ [-Wunused-variable]
3560 | RegisterList *texcoord_reg = spv_getreg(ctx, texcoord_arg->regtype, texcoord_arg->regnum);
| ^~~~~~~~~~~~
[ 47%] Building C object CMakeFiles/mojoshader.dir/profiles/mojoshader_profile_common.c.o
[ 50%] Building C object CMakeFiles/mojoshader.dir/mojoshader_effects.c.o
[ 52%] Building C object CMakeFiles/mojoshader.dir/mojoshader_compiler.c.o
[ 55%] Building C object CMakeFiles/mojoshader.dir/mojoshader_preprocessor.c.o
/mnt/data/gm/fna/src/MojoShader/mojoshader_compiler.c: In function ‘convert_to_lemon_token’:
/mnt/data/gm/fna/src/MojoShader/mojoshader_compiler.c:3441:9: warning: case value ‘33’ not in enumerated type ‘Token’ [-Wswitch]
3441 | case ((Token) '!'): return TOKEN_HLSL_EXCLAMATION;
| ^~~~
/mnt/data/gm/fna/src/MojoShader/mojoshader_compiler.c:3440:9: warning: case value ‘37’ not in enumerated type ‘Token’ [-Wswitch]
3440 | case ((Token) '%'): return TOKEN_HLSL_PERCENT;
| ^~~~
/mnt/data/gm/fna/src/MojoShader/mojoshader_compiler.c:3427:9: warning: case value ‘38’ not in enumerated type ‘Token’ [-Wswitch]
3427 | case ((Token) '&'): return TOKEN_HLSL_AND;
| ^~~~
/mnt/data/gm/fna/src/MojoShader/mojoshader_compiler.c:3448:9: warning: case value ‘40’ not in enumerated type ‘Token’ [-Wswitch]
3448 | case ((Token) '('): return TOKEN_HLSL_LPAREN;
| ^~~~
/mnt/data/gm/fna/src/MojoShader/mojoshader_compiler.c:3449:9: warning: case value ‘41’ not in enumerated type ‘Token’ [-Wswitch]
3449 | case ((Token) ')'): return TOKEN_HLSL_RPAREN;
| ^~~~
/mnt/data/gm/fna/src/MojoShader/mojoshader_compiler.c:3438:9: warning: case value ‘42’ not in enumerated type ‘Token’ [-Wswitch]
3438 | case ((Token) '*'): return TOKEN_HLSL_STAR;
| ^~~~
/mnt/data/gm/fna/src/MojoShader/mojoshader_compiler.c:3436:9: warning: case value ‘43’ not in enumerated type ‘Token’ [-Wswitch]
3436 | case ((Token) '+'): return TOKEN_HLSL_PLUS;
| ^~~~
/mnt/data/gm/fna/src/MojoShader/mojoshader_compiler.c:3410:9: warning: case value ‘44’ not in enumerated type ‘Token’ [-Wswitch]
3410 | case ((Token) ','): return TOKEN_HLSL_COMMA;
| ^~~~
/mnt/data/gm/fna/src/MojoShader/mojoshader_compiler.c:3437:9: warning: case value ‘45’ not in enumerated type ‘Token’ [-Wswitch]
3437 | case ((Token) '-'): return TOKEN_HLSL_MINUS;
| ^~~~
/mnt/data/gm/fna/src/MojoShader/mojoshader_compiler.c:3445:9: warning: case value ‘46’ not in enumerated type ‘Token’ [-Wswitch]
3445 | case ((Token) '.'): return TOKEN_HLSL_DOT;
| ^~~~
/mnt/data/gm/fna/src/MojoShader/mojoshader_compiler.c:3439:9: warning: case value ‘47’ not in enumerated type ‘Token’ [-Wswitch]
3439 | case ((Token) '/'): return TOKEN_HLSL_SLASH;
| ^~~~
/mnt/data/gm/fna/src/MojoShader/mojoshader_compiler.c:3453:9: warning: case value ‘58’ not in enumerated type ‘Token’ [-Wswitch]
3453 | case ((Token) ':'): return TOKEN_HLSL_COLON;
| ^~~~
/mnt/data/gm/fna/src/MojoShader/mojoshader_compiler.c:3454:9: warning: case value ‘59’ not in enumerated type ‘Token’ [-Wswitch]
3454 | case ((Token) ';'): return TOKEN_HLSL_SEMICOLON;
| ^~~~
/mnt/data/gm/fna/src/MojoShader/mojoshader_compiler.c:3430:9: warning: case value ‘60’ not in enumerated type ‘Token’ [-Wswitch]
3430 | case ((Token) '<'): return TOKEN_HLSL_LT;
| ^~~~
/mnt/data/gm/fna/src/MojoShader/mojoshader_compiler.c:3411:9: warning: case value ‘61’ not in enumerated type ‘Token’ [-Wswitch]
3411 | case ((Token) '='): return TOKEN_HLSL_ASSIGN;
| ^~~~
/mnt/data/gm/fna/src/MojoShader/mojoshader_compiler.c:3432:9: warning: case value ‘62’ not in enumerated type ‘Token’ [-Wswitch]
3432 | case ((Token) '>'): return TOKEN_HLSL_GT;
| ^~~~
/mnt/data/gm/fna/src/MojoShader/mojoshader_compiler.c:3422:9: warning: case value ‘63’ not in enumerated type ‘Token’ [-Wswitch]
3422 | case ((Token) '?'): return TOKEN_HLSL_QUESTION;
| ^~~~
/mnt/data/gm/fna/src/MojoShader/mojoshader_compiler.c:3446:9: warning: case value ‘91’ not in enumerated type ‘Token’ [-Wswitch]
3446 | case ((Token) '['): return TOKEN_HLSL_LBRACKET;
| ^~~~
/mnt/data/gm/fna/src/MojoShader/mojoshader_compiler.c:3447:9: warning: case value ‘93’ not in enumerated type ‘Token’ [-Wswitch]
3447 | case ((Token) ']'): return TOKEN_HLSL_RBRACKET;
| ^~~~
/mnt/data/gm/fna/src/MojoShader/mojoshader_compiler.c:3426:9: warning: case value ‘94’ not in enumerated type ‘Token’ [-Wswitch]
3426 | case ((Token) '^'): return TOKEN_HLSL_XOR;
| ^~~~
/mnt/data/gm/fna/src/MojoShader/mojoshader_compiler.c:3455:9: warning: case value ‘123’ not in enumerated type ‘Token’ [-Wswitch]
3455 | case ((Token) '{'): return TOKEN_HLSL_LBRACE;
| ^~~~
/mnt/data/gm/fna/src/MojoShader/mojoshader_compiler.c:3425:9: warning: case value ‘124’ not in enumerated type ‘Token’ [-Wswitch]
3425 | case ((Token) '|'): return TOKEN_HLSL_OR;
| ^~~~
/mnt/data/gm/fna/src/MojoShader/mojoshader_compiler.c:3456:9: warning: case value ‘125’ not in enumerated type ‘Token’ [-Wswitch]
3456 | case ((Token) '}'): return TOKEN_HLSL_RBRACE;
| ^~~~
/mnt/data/gm/fna/src/MojoShader/mojoshader_compiler.c:3442:9: warning: case value ‘126’ not in enumerated type ‘Token’ [-Wswitch]
3442 | case ((Token) '~'): return TOKEN_HLSL_COMPLEMENT;
| ^~~~
/mnt/data/gm/fna/src/MojoShader/mojoshader_preprocessor.c: In function ‘handle_pp_error’:
/mnt/data/gm/fna/src/MojoShader/mojoshader_preprocessor.c:899:13: warning: case value ‘10’ not in enumerated type ‘Token’ [-Wswitch]
899 | case ((Token) '\n'):
| ^~~~
/mnt/data/gm/fna/src/MojoShader/mojoshader_preprocessor.c:908:13: warning: case value ‘32’ not in enumerated type ‘Token’ [-Wswitch]
908 | case ((Token) ' '):
| ^~~~
/mnt/data/gm/fna/src/MojoShader/mojoshader_preprocessor.c: In function ‘handle_pp_define’:
/mnt/data/gm/fna/src/MojoShader/mojoshader_preprocessor.c:1068:13: warning: case value ‘10’ not in enumerated type ‘Token’ [-Wswitch]
1068 | case ((Token) '\n'):
| ^~~~
/mnt/data/gm/fna/src/MojoShader/mojoshader_preprocessor.c:1072:13: warning: case value ‘32’ not in enumerated type ‘Token’ [-Wswitch]
1072 | case ((Token) ' '): // may not actually point to ' '.
| ^~~~
/mnt/data/gm/fna/src/MojoShader/mojoshader_preprocessor.c: In function ‘reduce_pp_expression’:
/mnt/data/gm/fna/src/MojoShader/mojoshader_preprocessor.c:1721:13: warning: case value ‘10’ not in enumerated type ‘Token’ [-Wswitch]
1721 | case ((Token) '\n'):
| ^~~~
/mnt/data/gm/fna/src/MojoShader/mojoshader_preprocessor.c:1765:13: warning: case value ‘40’ not in enumerated type ‘Token’ [-Wswitch]
1765 | case ((Token) '('):
| ^~~~
/mnt/data/gm/fna/src/MojoShader/mojoshader_preprocessor.c:1769:13: warning: case value ‘41’ not in enumerated type ‘Token’ [-Wswitch]
1769 | case ((Token) ')'):
| ^~~~
[ 57%] Building C object CMakeFiles/mojoshader.dir/mojoshader_lexer.c.o
[ 60%] Building C object CMakeFiles/mojoshader.dir/mojoshader_assembler.c.o
[ 62%] Linking C static library libmojoshader.a
[ 65%] Built target mojoshader
Scanning dependencies of target mojoshader-compiler
Scanning dependencies of target testoutput
[ 70%] Building C object CMakeFiles/mojoshader-compiler.dir/utils/mojoshader-compiler.c.o
[ 70%] Building C object CMakeFiles/testoutput.dir/utils/testoutput.c.o
[ 72%] Linking C executable testoutput
[ 75%] Linking C executable mojoshader-compiler
[ 75%] Built target testoutput
Scanning dependencies of target testparse
[ 77%] Building C object CMakeFiles/testparse.dir/utils/testparse.c.o
[ 77%] Built target mojoshader-compiler
Scanning dependencies of target finderrors
[ 80%] Building C object CMakeFiles/finderrors.dir/utils/finderrors.c.o
[ 82%] Linking C executable testparse
[ 82%] Built target testparse
Scanning dependencies of target testglcompile
[ 85%] Building C object CMakeFiles/testglcompile.dir/utils/testglcompile.c.o
[ 87%] Linking C executable finderrors
[ 87%] Built target finderrors
Scanning dependencies of target availableprofiles
[ 90%] Building C object CMakeFiles/availableprofiles.dir/utils/availableprofiles.c.o
[ 92%] Linking C executable testglcompile
[ 92%] Built target testglcompile
Scanning dependencies of target bestprofile
[ 95%] Building C object CMakeFiles/bestprofile.dir/utils/bestprofile.c.o
[ 97%] Linking C executable availableprofiles
[ 97%] Built target availableprofiles
[100%] Linking C executable bestprofile
[100%] Built target bestprofile
Looks like an issue either with the system tools or lemon. Either way, this is just a mirror of MojoShader for FNA and not upstream so you'll need to contact Ryan instead if you're not building FNA3D.
Hi,
Getting segmentation fault when trying to compile:
System info:
Let me know if I can provide any other info. Thanks.
Edit- For some reason building debug version works: