Fet executable size fixed without changes to the system

Started by MarioMic, May 14, 2014, 09:23:22 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

MarioMic

Hello Liviu,
I tried to compile fet on Fedora 20 x86_64 forgetting to change the line with QMAKE_CFLAGS_RELEASE in the system file /usr/lib64/qt5/mkspecs/linux-g++-64/qmake.conf and I got the two executables in the following sizes:
- fet-cl: 25.9MB (expected: 3.4MB);
- fet: 220.1MB (expected: 11.5MB).

To avoid changing the system files I have tried alternative solutions by adding the line linux*-g++*:QMAKE_CXXFLAGS_RELEASE -= -g in the file fet.pro (to override the system settings) without success.

Later, after several searches on google (a useful reference: http://qt-project.org/forums/viewthread/10020), I realized that the added variable in fet.pro was not propagated in the subprojects, and I found two alternative working solutions:

  • the addition of the line "linux*-g++*:QMAKE_CXXFLAGS_RELEASE -= -g" in the files src/src.pro and src/src-cl.pro;
  • the addition of the hidden file .qmake.cache, containing the line "linux*-g++*:QMAKE_CXXFLAGS_RELEASE -= -g" (and eventually all the useful common stuff), in the directory of the main project.
What do you think?

Volker Dirr

#1
ah. ok. i see. it is an "improvement" of  the "Note 2" in "README" (see fet directory). let's see what Liviu think but i don't see disadvantages if that is added.
just to understand correct: you only need to add that line in src/src.pro and src/src-cl.pro. It doesn't work in fet.pro.

Liviu Lalescu

I am not sure, but I prefer not to mess with those flags myself. The GNU/Linux programmers know better when to add '-g'. And if the user wants, I instruct him how to do that. I will add in the README a note on this alternative, but I think it is better not to add the line myself in src.pro and src-cl.pro.

Liviu Lalescu

MarioMic, could you please verify if these work:

---
   Another solution, by another user: the addition of the lines
    "linux-g++: QMAKE_CXXFLAGS_RELEASE -= -g"
    and
    "linux-g++: QMAKE_CFLAGS_RELEASE -= -g"
    (without quotes) in the files src/src.pro and src/src-cl.pro (you can add them at the end of these files, or in another proper location).
---

MarioMic

I made the test and it does not work on my x86_64...
the compilation on my system is made with -I/usr/lib64/qt5/mkspecs/linux-g++-64, where is the file qmake.conf:
#
# qmake configuration for linux-g++
#
# Written for GNU/Linux platforms that have both lib and lib64 directories,
# like the AMD Opteron.
#

MAKEFILE_GENERATOR      = UNIX
CONFIG                 += incremental gdb_dwarf_index
QMAKE_INCREMENTAL_STYLE = sublib

QMAKE_CFLAGS            = -m64
QMAKE_LFLAGS            = -m64

QMAKE_CFLAGS_RELEASE   += -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2  -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic

include(../common/linux.conf)
include(../common/gcc-base-unix.conf)
include(../common/g++-unix.conf)


QMAKE_LIBDIR_X11        = /usr/X11R6/lib64
QMAKE_LIBDIR_OPENGL     = /usr/X11R6/lib64

load(qt_config)


Anyway, in my case:


  • NO: addition of the lines
        "linux-g++: QMAKE_CXXFLAGS_RELEASE -= -g"
        and
        "linux-g++: QMAKE_CFLAGS_RELEASE -= -g"
        (without quotes) in the files src/src.pro and src/src-cl.pro

  • YES: addition of the lines
        "linux-g++-64: QMAKE_CXXFLAGS_RELEASE -= -g"
        and
        "linux-g++-64: QMAKE_CFLAGS_RELEASE -= -g"
        (or the more generic linux-g++*) in the files src/src.pro and src/src-cl.pro

  • NO: addition of the lines
        "linux-g++-64: QMAKE_CFLAGS_RELEASE -= -g"
        (without quotes) in the files src/src.pro and src/src-cl.pro

  • YES: addition of the lines
        "linux-g++-64: QMAKE_CXXFLAGS_RELEASE -= -g"
        (without quotes) in the files src/src.pro and src/src-cl.pro

MarioMic

If it can be useful, on my system in /usr/lib64/qt5/mkspecs/linux-g++ the file qmake.conf is:

#
# qmake configuration for linux-g++
#

MAKEFILE_GENERATOR      = UNIX
CONFIG                 += incremental gdb_dwarf_index
QMAKE_INCREMENTAL_STYLE = sublib

QMAKE_CFLAGS_RELEASE   += -O2

include(../common/linux.conf)
include(../common/gcc-base-unix.conf)
include(../common/g++-unix.conf)
load(qt_config)


../common/linux.conf:
#
# qmake configuration for common linux
#

QMAKE_PLATFORM         += linux

QMAKE_CFLAGS_THREAD    += -D_REENTRANT
QMAKE_CXXFLAGS_THREAD  += $$QMAKE_CFLAGS_THREAD

QMAKE_INCDIR            =
QMAKE_LIBDIR            =
QMAKE_INCDIR_X11        =
QMAKE_LIBDIR_X11        =
QMAKE_INCDIR_OPENGL     =
QMAKE_LIBDIR_OPENGL     =
QMAKE_INCDIR_OPENGL_ES1 = $$QMAKE_INCDIR_OPENGL
QMAKE_LIBDIR_OPENGL_ES1 = $$QMAKE_LIBDIR_OPENGL
QMAKE_INCDIR_OPENGL_ES2 = $$QMAKE_INCDIR_OPENGL
QMAKE_LIBDIR_OPENGL_ES2 = $$QMAKE_LIBDIR_OPENGL
QMAKE_INCDIR_EGL        =
QMAKE_LIBDIR_EGL        =
QMAKE_INCDIR_OPENVG     =
QMAKE_LIBDIR_OPENVG     =

QMAKE_LIBS              =
QMAKE_LIBS_DYNLOAD      = -ldl
QMAKE_LIBS_X11          = -lXext -lX11 -lm
QMAKE_LIBS_NIS          = -lnsl
QMAKE_LIBS_EGL          = -lEGL
QMAKE_LIBS_OPENGL       = -lGL
QMAKE_LIBS_OPENGL_ES1   = -lGLESv1_CM
QMAKE_LIBS_OPENGL_ES2   = -lGLESv2
QMAKE_LIBS_OPENVG       = -lOpenVG
QMAKE_LIBS_THREAD       = -lpthread
QMAKE_LIBS_LIBUDEV      = -ludev

QMAKE_CFLAGS_WAYLAND    =
QMAKE_INCDIR_WAYLAND    =
QMAKE_LIBS_WAYLAND_CLIENT = -lwayland-client
QMAKE_LIBS_WAYLAND_SERVER = -lwayland-server
QMAKE_LIBDIR_WAYLAND    =
QMAKE_DEFINES_WAYLAND   =
QMAKE_WAYLAND_SCANNER   = wayland-scanner

QMAKE_CFLAGS_XCB        =
QMAKE_LIBS_XCB          =
QMAKE_DEFINES_XCB       =

QMAKE_AR                = ar cqs
QMAKE_OBJCOPY           = objcopy
QMAKE_NM                = nm -P
QMAKE_RANLIB            =

QMAKE_STRIP             =
QMAKE_STRIPFLAGS_LIB   +=
QMAKE_INSTALL_FILE      = install -m 644 -p
QMAKE_INSTALL_PROGRAM   = install -m 755 -p

include(unix.conf)


unix.conf:
#
# qmake configuration for common unix
#

QMAKE_PLATFORM         += unix posix

QMAKE_LEX               = flex
QMAKE_LEXFLAGS         +=
QMAKE_YACC              = yacc
QMAKE_YACCFLAGS        += -d
QMAKE_YACCFLAGS_MANGLE += -p $base -b $base
QMAKE_YACC_HEADER       = $base.tab.h
QMAKE_YACC_SOURCE       = $base.tab.c
QMAKE_PREFIX_SHLIB      = lib
QMAKE_PREFIX_STATICLIB  = lib
QMAKE_EXTENSION_STATICLIB = a

include(shell-unix.conf)


shell-unix.conf:
QMAKE_TAR               = tar -cf
QMAKE_GZIP              = gzip -9f

QMAKE_COPY              = cp -f
QMAKE_COPY_FILE         = $$QMAKE_COPY
QMAKE_COPY_DIR          = $$QMAKE_COPY -R
QMAKE_MOVE              = mv -f
QMAKE_DEL_FILE          = rm -f
QMAKE_DEL_DIR           = rmdir
QMAKE_CHK_EXISTS        = test -e %1 ||
QMAKE_CHK_DIR_EXISTS    = test -d    # legacy
QMAKE_MKDIR             = mkdir -p   # legacy
QMAKE_MKDIR_CMD         = test -d %1 || mkdir -p %1
QMAKE_STREAM_EDITOR     = sed


../common/gcc-base-unix.conf:
#
# Base qmake configuration for GCC on *nix-systems
#
# Before making changes to this file, please read the comment in
# gcc-base.conf, to make sure the change goes in the right place.
#
# To verify that your change has the desired effect on the final configuration
# you can use the manual test in tests/manual/mkspecs.
#

include(gcc-base.conf)

QMAKE_LFLAGS_SHLIB     += -shared
QMAKE_LFLAGS_PLUGIN    += $$QMAKE_LFLAGS_SHLIB
QMAKE_LFLAGS_SONAME    += -Wl,-soname,
QMAKE_LFLAGS_THREAD    +=
QMAKE_LFLAGS_RPATH      = -Wl,-rpath,
QMAKE_LFLAGS_RPATHLINK  = -Wl,-rpath-link,

# -Bsymbolic-functions (ld) support
QMAKE_LFLAGS_BSYMBOLIC_FUNC = -Wl,-Bsymbolic-functions
QMAKE_LFLAGS_DYNAMIC_LIST   = -Wl,--dynamic-list,


gcc-base.conf:
#
# This file is used as a basis for the following compilers:
#
# - The GNU C++ compiler (g++)
# - LLVM
# - Clang
#
# Platform-specific options shared by these compilers are put into:
#
# - gcc-base-mac.conf
# - gcc-base-unix.conf
#
# These base files are then combined with configurations for each compiler:
#
# - g++-base.conf
# - g++-macx.conf
# - g++-unix.conf
# - llvm.conf
# - clang.conf
#
# The combination happens in the top level mkspec, by including a platform-
# specific version of the base-file, for example gcc-base-mac.conf, and then
# a (possibly platform-specific) version of the actual compiler configuration,
# for example g++-macx.conf.
#
# If you are making changes to any of these files, please consider the
# possible effect it may have due to these include-rules, and whether it
# might make more sense to share the rule or make it more specific.
#
# To verify that your change has the desired effect on the final configuration
# you can use the manual test in tests/manual/mkspecs.
#

QMAKE_CFLAGS               += -pipe
QMAKE_CFLAGS_DEPS          += -M
QMAKE_CFLAGS_WARN_ON       += -Wall -W
QMAKE_CFLAGS_WARN_OFF      += -w
QMAKE_CFLAGS_RELEASE       += -O2
QMAKE_CFLAGS_DEBUG         += -g
QMAKE_CFLAGS_SHLIB         += -fPIC
QMAKE_CFLAGS_STATIC_LIB    += -fPIC
QMAKE_CFLAGS_APP           += -fPIE
QMAKE_CFLAGS_YACC          += -Wno-unused -Wno-parentheses
QMAKE_CFLAGS_HIDESYMS      += -fvisibility=hidden
QMAKE_CFLAGS_EXCEPTIONS_OFF += -fno-exceptions

QMAKE_CXXFLAGS            += $$QMAKE_CFLAGS
QMAKE_CXXFLAGS_DEPS       += $$QMAKE_CFLAGS_DEPS
QMAKE_CXXFLAGS_WARN_ON    += $$QMAKE_CFLAGS_WARN_ON
QMAKE_CXXFLAGS_WARN_OFF   += $$QMAKE_CFLAGS_WARN_OFF
QMAKE_CXXFLAGS_RELEASE    += $$QMAKE_CFLAGS_RELEASE
QMAKE_CXXFLAGS_DEBUG      += $$QMAKE_CFLAGS_DEBUG
QMAKE_CXXFLAGS_SHLIB      += $$QMAKE_CFLAGS_SHLIB
QMAKE_CXXFLAGS_STATIC_LIB += $$QMAKE_CFLAGS_STATIC_LIB
QMAKE_CXXFLAGS_APP        += $$QMAKE_CFLAGS_APP
QMAKE_CXXFLAGS_YACC       += $$QMAKE_CFLAGS_YACC
QMAKE_CXXFLAGS_HIDESYMS   += $$QMAKE_CFLAGS_HIDESYMS -fvisibility-inlines-hidden
QMAKE_CXXFLAGS_EXCEPTIONS_OFF += $$QMAKE_CFLAGS_EXCEPTIONS_OFF

QMAKE_LFLAGS           +=
QMAKE_LFLAGS_DEBUG     +=
QMAKE_LFLAGS_APP       +=
QMAKE_LFLAGS_RELEASE   +=
QMAKE_LFLAGS_EXCEPTIONS_OFF +=

QMAKE_CFLAGS_SSE2      += -msse2
QMAKE_CFLAGS_SSE3      += -msse3
QMAKE_CFLAGS_SSSE3     += -mssse3
QMAKE_CFLAGS_SSE4_1    += -msse4.1
QMAKE_CFLAGS_SSE4_2    += -msse4.2
QMAKE_CFLAGS_AVX       += -mavx
QMAKE_CFLAGS_AVX2      += -mavx2
QMAKE_CFLAGS_IWMMXT    += -mcpu=iwmmxt
QMAKE_CFLAGS_NEON      += -mfpu=neon


../common/g++-unix.conf:
#
# Qmake configuration for the GNU C++ compiler on *nix-systems
#
# Before making changes to this file, please read the comment in
# gcc-base.conf, to make sure the change goes in the right place.
#
# To verify that your change has the desired effect on the final configuration
# you can use the manual test in tests/manual/mkspecs.
#

include(g++-base.conf)

QMAKE_LFLAGS_RELEASE   += -Wl,-O1 -Wl,-z,relro
QMAKE_LFLAGS_NOUNDEF   += -Wl,--no-undefined


../common/g++-unix.conf:
#
# Qmake configuration for the GNU C++ compiler
#
# Before making changes to this file, please read the comment in
# gcc-base.conf, to make sure the change goes in the right place.
#
# To verify that your change has the desired effect on the final configuration
# you can use the manual test in tests/manual/mkspecs.
#

QMAKE_COMPILER          = gcc

QMAKE_CC                = gcc

QMAKE_LINK_C            = $$QMAKE_CC
QMAKE_LINK_C_SHLIB      = $$QMAKE_CC

QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += -O2 -g

QMAKE_CXX               = g++

QMAKE_LINK              = $$QMAKE_CXX
QMAKE_LINK_SHLIB        = $$QMAKE_CXX

QMAKE_CXXFLAGS_RELEASE_WITH_DEBUGINFO += $$QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO

QMAKE_PCH_OUTPUT_EXT    = .gch

QMAKE_CFLAGS_PRECOMPILE       = -x c-header -c ${QMAKE_PCH_INPUT} -o ${QMAKE_PCH_OUTPUT}
QMAKE_CFLAGS_USE_PRECOMPILE   = -include ${QMAKE_PCH_OUTPUT_BASE}
QMAKE_CXXFLAGS_PRECOMPILE     = -x c++-header -c ${QMAKE_PCH_INPUT} -o ${QMAKE_PCH_OUTPUT}
QMAKE_CXXFLAGS_USE_PRECOMPILE = $$QMAKE_CFLAGS_USE_PRECOMPILE

QMAKE_CXXFLAGS_CXX11    = -std=c++0x
QMAKE_LFLAGS_CXX11      =

Liviu Lalescu

Thank you! I added this:

---
   Another solution, by another user: the addition of the lines
    "linux-g++*: QMAKE_CXXFLAGS_RELEASE -= -g"
    and
    "linux-g++*: QMAKE_CFLAGS_RELEASE -= -g"
    (without quotes) in the files src/src.pro and src/src-cl.pro (you can add them at the end of these files, or in another proper location).
---

MarioMic

Quote from: Volker Dirr on May 14, 2014, 10:00:30 PM
ah. ok. i see. it is an "improvement" of  the "Note 2" in "README" (see fet directory). let's see what Liviu think but i don't see disadvantages if that is added.
just to understand correct: you only need to add that line in src/src.pro and src/src-cl.pro. It doesn't work in fet.pro.

Excuse me, Volker Dirr, I forgot to reply to you.
Yes, the fet.pro modified has no effect because the statement about CFLAGS and CXXFLAGS was not propagated to the subprojects fet.pro and fet-cl.pro. I have to add the statement in the two subprojects files or, if there was an include(../common.conf) in these two files I could just change the file common.conf.

The alternative solution of the hidden file .qmake.cache has two drawbacks:

  • is an hidden file and it might not be noticed, it might be forgotten, overlooked;
  • if -nocache is specified when qmake is run, the hidden file is ignored and it will not be processed.

Volker Dirr

#8
thinking some more time I see a drawback/disadvantage if that is added into the .pro files.

If that "bugfix" will be added you will still have the same problem to all your other software which you are compiling. So do you want to ask all coders to changes their makefile/pro-file also?

So I think there are only option:
You should ask the the fedora guys to fix this "bug" in the .qmake.cache file.
There will be only 2 possible answers:
a) The fedora coders agree and change the .qmake.cache file. So not only fet will be "fixed" by that. Also all other software projects will be fixed by that.
b) The fedora coders don't agree because they set the debugger flag on purpose because it is needed by the coders and bughunters for debugging software. I guess in that case Fedora might be not the perfect distribution in your case and you must modify that file yourself or change the distribution.