Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NanoVG link-phase warnings when using g++ "-O3 -flto" optimization flags. #39

Open
NielsMayer opened this issue Dec 11, 2018 · 0 comments

Comments

@NielsMayer
Copy link
Contributor

I recompiled the latest QNanoPainter after adding the following optimization tweaks to libqnanopainter/include.pri

## NPM: Turn optimization up to 11 for Release build.
## NPM: Use optimized debugging "-Og enables optimizations that do not interfere with debugging. It should be the optimization level of choice for the standard edit-compile-debug cycle, offering a reasonable level of optimization while maintaining fast compilation and a good debugging experience."
## https://gcc.gnu.org/onlinedocs/gcc-4.9.2/gcc/Optimize-Options.html
QMAKE_CFLAGS_OPTIMIZE_SIZE =  ##note that /opt/Qt5.12.0/5.12.0/android_armv7/mkspecs/common/gcc-base.conf sets this to "-Os" and uses for Android Arm builds (only) automatically. This unsets it and gives full optimized android arm builds.
QMAKE_CFLAGS_RELEASE   = -flto -ffast-math -O3
QMAKE_CFLAGS_DEBUG     = -g -Og
QMAKE_CXXFLAGS_RELEASE = -flto -ffast-math -O3
QMAKE_CXXFLAGS_DEBUG   = -g -Og
QMAKE_LFLAGS_RELEASE   = -flto -O3
QMAKE_LFLAGS_DEBUG     = -g -Og

In linking, the following strange warnings are produced related to NanoVG:

g++ -flto -O3 -Wl,-rpath,/opt/Qt5.12.0/5.12.0/gcc_64/lib -o qnanopainter_vs_qpainter_demo main.o demoqpitem.o demoqnanoitem.o demoqnanoitempainter.o qnanopainter.o qnanocolor.o qnanolineargradient.o qnanoimagepattern.o qnanoimage.o qnanofont.o qnanoradialgradient.o qnanoboxgradient.o qnanowindow.o qnanodebug.o qnanoquickitem.o qnanoquickitempainter.o qnanobackendgl2.o qnanobackendgl3.o nanovg.o qrc_qml_qmlcache.o qrc_libqnanopainterdata.o main_qml.o qml_Button_qml.o qml_FpsItem_qml.o qml_TabView_qml.o qml_SliderSelector_qml.o qml_Switch_qml.o qml_SettingsView_qml.o qml_shapeitem_RulerComponent_qml.o qml_shapeitem_FlowerComponent_qml.o qml_shapeitem_LinesComponent_qml.o qml_shapeitem_DemoShapeItem_qml.o qml_shapeitem_BarsComponent_qml.o qml_shapeitem_IconsComponent_qml.o qml_shapeitem_CirclesComponent_qml.o qmlcache_loader.o moc_demoqpitem.o moc_demoqnanoitem.o moc_qnanowindow.o moc_qnanoquickitem.o   -L/opt/Qt5.12.0/5.12.0/gcc_64/lib -lQt5Quick -lQt5Gui -lQt5Qml -lQt5Network -lQt5Core -lGL -lpthread   
../../../qnanopainter/libqnanopainter/nanovg/nanovg_gl_wrapped.h:231:8: warning: type ‘struct GLNVGcontext’ violates the C++ One Definition Rule [-Wodr]
 struct GLNVGcontext {
        ^
make[1]: Leaving directory '/usr/local/src/build-qnanopainter-Qt5_12_0_Desktop_GCC_C_x86_64bit_in_usr_bin-Release/examples/helloitem'
../../../qnanopainter/libqnanopainter/nanovg/nanovg_gl_wrapped.h:231:8: note: a different type is defined in another translation unit
 struct GLNVGcontext {
        ^
../../../qnanopainter/libqnanopainter/nanovg/nanovg_gl_wrapped.h:245:6: note: the first difference of corresponding definitions is field ‘fragSize’
  int fragSize;
      ^
../../../qnanopainter/libqnanopainter/nanovg/nanovg_gl_wrapped.h:240:9: note: a field with different name is defined in another translation unit
  GLuint vertArr;
         ^
../../../qnanopainter/libqnanopainter/nanovg/nanovg_gl_wrapped.h:231:8: warning: type ‘struct GLNVGcontext’ violates the C++ One Definition Rule [-Wodr]
 struct GLNVGcontext {
        ^
../../../qnanopainter/libqnanopainter/nanovg/nanovg_gl_wrapped.h:231:8: note: a different type is defined in another translation unit
 struct GLNVGcontext {
        ^
../../../qnanopainter/libqnanopainter/nanovg/nanovg_gl_wrapped.h:245:6: note: the first difference of corresponding definitions is field ‘fragSize’
  int fragSize;
      ^
../../../qnanopainter/libqnanopainter/nanovg/nanovg_gl_wrapped.h:240:9: note: a field with different name is defined in another translation unit
  GLuint vertArr;
         ^
make[1]: Leaving directory '/usr/local/src/build-qnanopainter-Qt5_12_0_Desktop_GCC_C_x86_64bit_in_usr_bin-Release/examples/hellowindow'
../../../qnanopainter/libqnanopainter/nanovg/nanovg_gl_wrapped.h:231:8: warning: type ‘struct GLNVGcontext’ violates the C++ One Definition Rule [-Wodr]
 struct GLNVGcontext {
        ^
../../../qnanopainter/libqnanopainter/nanovg/nanovg_gl_wrapped.h:231:8: note: a different type is defined in another translation unit
 struct GLNVGcontext {
        ^
../../../qnanopainter/libqnanopainter/nanovg/nanovg_gl_wrapped.h:245:6: note: the first difference of corresponding definitions is field ‘fragSize’
  int fragSize;
      ^
../../../qnanopainter/libqnanopainter/nanovg/nanovg_gl_wrapped.h:240:9: note: a field with different name is defined in another translation unit
  GLuint vertArr;
         ^
make[1]: Leaving directory '/usr/local/src/build-qnanopainter-Qt5_12_0_Desktop_GCC_C_x86_64bit_in_usr_bin-Release/examples/gallery'
../../../qnanopainter/libqnanopainter/nanovg/nanovg_gl_wrapped.h:231:8: warning: type ‘struct GLNVGcontext’ violates the C++ One Definition Rule [-Wodr]
 struct GLNVGcontext {
        ^
../../../qnanopainter/libqnanopainter/nanovg/nanovg_gl_wrapped.h:231:8: note: a different type is defined in another translation unit
 struct GLNVGcontext {
        ^
../../../qnanopainter/libqnanopainter/nanovg/nanovg_gl_wrapped.h:245:6: note: the first difference of corresponding definitions is field ‘fragSize’
  int fragSize;
      ^
../../../qnanopainter/libqnanopainter/nanovg/nanovg_gl_wrapped.h:240:9: note: a field with different name is defined in another translation unit
  GLuint vertArr;
         ^
make[1]: Leaving directory '/usr/local/src/build-qnanopainter-Qt5_12_0_Desktop_GCC_C_x86_64bit_in_usr_bin-Release/examples/hellowidget'
../../../qnanopainter/libqnanopainter/nanovg/nanovg_gl_wrapped.h:231:8: warning: type ‘struct GLNVGcontext’ violates the C++ One Definition Rule [-Wodr]
 struct GLNVGcontext {
        ^
../../../qnanopainter/libqnanopainter/nanovg/nanovg_gl_wrapped.h:231:8: note: a different type is defined in another translation unit
 struct GLNVGcontext {
        ^
../../../qnanopainter/libqnanopainter/nanovg/nanovg_gl_wrapped.h:245:6: note: the first difference of corresponding definitions is field ‘fragSize’
  int fragSize;
      ^
../../../qnanopainter/libqnanopainter/nanovg/nanovg_gl_wrapped.h:240:9: note: a field with different name is defined in another translation unit
  GLuint vertArr;
         ^

I am using Kubuntu 18.04LTS installed g++: "g++ (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant