bkaradzic / bimg

Image library.
BSD 2-Clause "Simplified" License
327 stars 268 forks source link

Fix compilation with gcc8/9 #57

Closed arves100 closed 3 years ago

arves100 commented 3 years ago

Under Gcc9 (Ubuntu 20 WSL) and Gcc8 (Debian 10), bimg will fail to compile due to sys/types.h already defining "uint", "ushort" and "ulong" types.

This commit skips the definition of this three types in vectypes.h if __USE_MISC is defined. (compatibility with old C names)

bkaradzic commented 3 years ago

I'm using gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0 and I don't see this issue.

arves100 commented 3 years ago

gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0

I'm using gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0 and I don't see this issue.

I'm using your same gcc version under WSL and I got this error, perhaps is something wrong I did during bgfx generation? I runned genie --with-avx --gcc=linux-gcc --platform=x64 then runned make config=debug64

bkaradzic commented 3 years ago

You don't need --platform=x64.

bkaradzic commented 3 years ago

I assume this issue might be something with WSL?

arves100 commented 3 years ago

I assume this issue might be something with WSL?

I got this error as well with Debian 10 (gcc 8) running on a real machine

arves100 commented 2 years ago

Hi, I'm terribly sorry to necroposting a June 2021 issue, but the issue is actually present, altrough my comment and name of the PR is 100% wrong. First of all, this issue is not raised up when using --platform=x64 or a normal 64-bit machine, as you pointed out that was why I was wrong when claiming it did, but this issue is actually raised up when compiling bgfx on a 32-bit platform (or using --platform=x32 on a 64-bit machine), not on old compiler or 64-bit platform as I originally said. I'm sorry again for giving a wrong information to this PR, feel free to let me know if it's actually some issue in my end.

The compilation was tested on a Debian 11 i686 machine with Gcc 10. My bgfx configuration command line: ../bx/tools/bin/linux/genie --with-tools --with-avx --gcc=linux-gcc gmake

q4a commented 2 years ago

Looks like I have same problem with building on arm32 Linux (Armbian/Ubuntu on rk3288). My build steps:

bgfx$ ../bx/tools/bin/linux/genie --with-tools --with-combined-examples --with-shared-lib --gcc=linux-arm-gcc gmake
bgfx$ make -j$(nproc) -C .build/projects/gmake-linux-arm-gcc config=release

and here is error:

==== Building bimg_encode (release) ====
astc_averages_and_directions.cpp
In file included from ../../../../bimg/3rdparty/astc/mathlib.h:20,
                 from ../../../../bimg/3rdparty/astc/astc_codec_internals.h:23,
                 from ../../../../bimg/3rdparty/astc/astc_averages_and_directions.cpp:17:
../../../../bimg/3rdparty/astc/vectypes.h:21:18: error: conflicting declaration ‘typedef uint64_t ulong’
   21 | typedef uint64_t ulong;
      |                  ^~~~~
In file included from /usr/include/stdlib.h:394,
                 from /usr/include/c++/9/cstdlib:75,
                 from /usr/include/c++/9/stdlib.h:36,
                 from ../../../../bimg/3rdparty/astc/astc_codec_internals.h:21,
                 from ../../../../bimg/3rdparty/astc/astc_averages_and_directions.cpp:17:
/usr/include/arm-linux-gnueabihf/sys/types.h:148:27: note: previous declaration as ‘typedef long unsigned int ulong’
  148 | typedef unsigned long int ulong;
      |                           ^~~~~
bkaradzic commented 2 years ago

Try: config=release32

q4a commented 2 years ago

Try: config=release32

It gives much more errors at start:

build log ``` bgfx$ make -j$(nproc) -C .build/projects/gmake-linux-arm-gcc config=release32 make: Entering directory '/home/q/git/bgfx-sample/bgfx/.build/projects/gmake-linux-arm-gcc' ==== Building bx (release32) ==== ==== Building fcpp (release32) ==== ==== Building glslang (release32) ==== ==== Building glsl-optimizer (release32) ==== Creating ../../linux32_arm_gcc/obj/x32/Release/fcpp Creating ../../linux32_arm_gcc/obj/x32/Release/bx Creating ../../linux32_arm_gcc/obj/x32/Release/fcpp/3rdparty/fcpp Creating ../../linux32_arm_gcc/obj/x32/Release/bx/bx/src Creating ../../linux32_arm_gcc/bin Creating ../../linux32_arm_gcc/obj/x32/Release/glsl-optimizer Creating ../../linux32_arm_gcc/obj/x32/Release/glslang Creating ../../linux32_arm_gcc/bin Creating ../../linux32_arm_gcc/obj/x32/Release/glslang/3rdparty/glslang/OGLCompilersDLL cpp1.c Creating ../../linux32_arm_gcc/obj/x32/Release/glsl-optimizer/3rdparty/glsl-optimizer/src/glsl allocator.cpp Creating ../../linux32_arm_gcc/obj/x32/Release/glslang/3rdparty/glslang/SPIRV Creating ../../linux32_arm_gcc/obj/x32/Release/glsl-optimizer/3rdparty/glsl-optimizer/src/glsl/glcpp Creating ../../linux32_arm_gcc/obj/x32/Release/glslang/3rdparty/glslang/SPIRV/CInterface Creating ../../linux32_arm_gcc/obj/x32/Release/glsl-optimizer/3rdparty/glsl-optimizer/src/mesa/main g++: error: unrecognized command line option ‘-m32’; did you mean ‘-mbe32’? make[1]: *** [bx.make:441: ../../linux32_arm_gcc/obj/x32/Release/bx/bx/src/allocator.o] Error 1 make: *** [Makefile:17: bx] Error 2 make: *** Waiting for unfinished jobs.... Creating ../../linux32_arm_gcc/obj/x32/Release/glslang/3rdparty/glslang/glslang/CInterface Creating ../../linux32_arm_gcc/obj/x32/Release/glsl-optimizer/3rdparty/glsl-optimizer/src/mesa/program Creating ../../linux32_arm_gcc/obj/x32/Release/glslang/3rdparty/glslang/glslang/GenericCodeGen cpp2.c Creating ../../linux32_arm_gcc/obj/x32/Release/glsl-optimizer/3rdparty/glsl-optimizer/src/util gcc: error: unrecognized command line option ‘-m32’; did you mean ‘-mbe32’? make[1]: *** [fcpp.make:339: ../../linux32_arm_gcc/obj/x32/Release/fcpp/3rdparty/fcpp/cpp1.o] Error 1 make[1]: *** Waiting for unfinished jobs.... Creating ../../linux32_arm_gcc/obj/x32/Release/glslang/3rdparty/glslang/glslang/HLSL Creating ../../linux32_arm_gcc/obj/x32/Release/glslang/3rdparty/glslang/glslang/MachineIndependent gcc: error: unrecognized command line option ‘-m32’; did you mean ‘-mbe32’? make[1]: *** [fcpp.make:343: ../../linux32_arm_gcc/obj/x32/Release/fcpp/3rdparty/fcpp/cpp2.o] Error 1 make: *** [Makefile:77: fcpp] Error 2 Creating ../../linux32_arm_gcc/obj/x32/Release/glslang/3rdparty/glslang/glslang/MachineIndependent/preprocessor ast_array_index.cpp ast_expr.cpp Creating ../../linux32_arm_gcc/obj/x32/Release/glslang/3rdparty/glslang/glslang/OSDependent/Unix g++: error: unrecognized command line option ‘-m32’; did you mean ‘-mbe32’? make[1]: *** [glsl-optimizer.make:937: ../../linux32_arm_gcc/obj/x32/Release/glsl-optimizer/3rdparty/glsl-optimizer/src/glsl/ast_array_index.o] Error 1 make[1]: *** Waiting for unfinished jobs.... g++: error: unrecognized command line option ‘-m32’; did you mean ‘-mbe32’? make[1]: *** [glsl-optimizer.make:941: ../../linux32_arm_gcc/obj/x32/Release/glsl-optimizer/3rdparty/glsl-optimizer/src/glsl/ast_expr.o] Error 1 make: *** [Makefile:73: glsl-optimizer] Error 2 Creating ../../linux32_arm_gcc/obj/x32/Release/glslang/3rdparty/glslang/glslang/OSDependent/Web InitializeDll.cpp Creating ../../linux32_arm_gcc/obj/x32/Release/glslang/3rdparty/glslang/hlsl spirv_c_interface.cpp GlslangToSpv.cpp InReadableOrder.cpp g++: error: unrecognized command line option ‘-m32’; did you mean ‘-mbe32’? make[1]: *** [glslang.make:635: ../../linux32_arm_gcc/obj/x32/Release/glslang/3rdparty/glslang/SPIRV/CInterface/spirv_c_interface.o] Error 1 make[1]: *** Waiting for unfinished jobs.... g++: error: unrecognized command line option ‘-m32’; did you mean ‘-mbe32’? make[1]: *** [glslang.make:639: ../../linux32_arm_gcc/obj/x32/Release/glslang/3rdparty/glslang/SPIRV/GlslangToSpv.o] Error 1 g++: error: unrecognized command line option ‘-m32’; did you mean ‘-mbe32’? g++: error: unrecognized command line option ‘-m32’; did you mean ‘-mbe32’? make[1]: *** [glslang.make:631: ../../linux32_arm_gcc/obj/x32/Release/glslang/3rdparty/glslang/OGLCompilersDLL/InitializeDll.o] Error 1 make[1]: *** [glslang.make:643: ../../linux32_arm_gcc/obj/x32/Release/glslang/3rdparty/glslang/SPIRV/InReadableOrder.o] Error 1 make: *** [Makefile:69: glslang] Error 2 make: Leaving directory '/home/q/git/bgfx-sample/bgfx/.build/projects/gmake-linux-arm-gcc' ```
q4a commented 2 years ago

Looks like bug appear after this PR: https://github.com/bkaradzic/bimg/pull/54 If you want to fix bug + improve code - you can update from upstream. This file was deleted there: https://github.com/ARM-software/astc-encoder/commit/9629e405129931554e6e6e634b360ff9d07ac7a2