You are not logged in.

#1 2015-03-06 00:00:28

enihcam
Member
From: Internet
Registered: 2009-12-20
Posts: 220

[SOLVED] C(XX)FLAGS does not work for QMAKE based packages.

/etc/makepkg.conf

...
#########################################################################
# ARCHITECTURE, COMPILE FLAGS
#########################################################################
#
CARCH="x86_64"
CHOST="x86_64-unknown-linux-gnu"

#-- Compiler and Linker Flags
# -march (or -mcpu) builds exclusively for an architecture
# -mtune optimizes for an architecture, but builds for whole processor family
CFLAGS="-march=native -mfpmath=sse -O2 -pipe"
CPPFLAGS="${CFLAGS}"
CXXFLAGS="${CFLAGS}"
LDFLAGS="-Wl,-O1,--sort-common,--as-needed,-z,relro"
#-- Make Flags: change this for DistCC/SMP systems
MAKEFLAGS="-j3"
#-- Debugging flags
DEBUG_CFLAGS=""
DEBUG_CXXFLAGS=""
...

'yaourt -S quiterss' (for example)

...
g++ -c -pipe -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong --param=ssp-buffer-size=4 -Wall -W -D_REENTRANT -DHAVE_PHONON -DHAVE_X11 -DRESOURCES_DIR=\"/usr/share/quiterss\" -DQT_NO_DEBUG -DQT_WEBKIT_LIB -DQT_PHONON_LIB -DQT_SQL_LIB -DQT_XML_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtNetwork -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtXml -I/usr/include/qt4/QtSql -I/usr/include/qt4/phonon -I/usr/include/qt4/QtWebKit -I/usr/include/qt4 -Isrc -Isrc/application -Isrc/common -Isrc/main -Isrc/database -Isrc/downloads -Isrc/newsfilters -Isrc/notifications -Isrc/plugins -Isrc/adblock -Isrc/network -Isrc/webview -I3rdparty/qtsingleapplication -I3rdparty -I3rdparty/sqlitex -I3rdparty/qyursqltreeview -Ilang -I/usr/include/qt4/phonon_compat -Irelease/moc -I. -o release/obj/moc_qyursqltreeview.o release/moc/moc_qyursqltreeview.cpp
...

Any ideas?

Last edited by enihcam (2015-03-08 09:06:38)

Offline

#2 2015-03-06 02:26:37

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,534
Website

Re: [SOLVED] C(XX)FLAGS does not work for QMAKE based packages.

It works fine here.  That output shows that it is infact picking up a C(XX)FLAGS envrionment variable as settings like mtune are not in the Makefile.  It's just picking up the wrong settings.  Try using makepkg instead of yaourt.

EDIT: and just for good measure, can you provide the full makepkg.conf.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#3 2015-03-06 02:31:30

enihcam
Member
From: Internet
Registered: 2009-12-20
Posts: 220

Re: [SOLVED] C(XX)FLAGS does not work for QMAKE based packages.

Trilby wrote:

It works fine here.  That output shows that it is infact picking up a C(XX)FLAGS envrionment variable as settings like mtune are not in the Makefile.  It's just picking up the wrong settings.  Try using makepkg instead of yaourt.

EDIT: and just for good measure, can you provide the full makepkg.conf.

Thanks. I'll open a bug to yaourt owner.

Offline

#4 2015-03-06 02:33:13

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,534
Website

Re: [SOLVED] C(XX)FLAGS does not work for QMAKE based packages.

Did it work with makepkg then?


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#5 2015-03-06 02:35:08

enihcam
Member
From: Internet
Registered: 2009-12-20
Posts: 220

Re: [SOLVED] C(XX)FLAGS does not work for QMAKE based packages.

@Trilby. I'll try when I get home. I can only give you the conf for now. Thanks for help.

nanw@archnet ~ $ cat /etc/makepkg.conf
#
# /etc/makepkg.conf
#

#########################################################################
# SOURCE ACQUISITION
#########################################################################
#
#-- The download utilities that makepkg should use to acquire sources
#  Format: 'protocol::agent'
DLAGENTS=('ftp::/usr/bin/curl -fC - --ftp-pasv --retry 3 --retry-delay 3 -o %o %                                                u'
          'http::/usr/bin/curl -fLC - --retry 3 --retry-delay 3 -o %o %u'
          'https::/usr/bin/curl -fLC - --retry 3 --retry-delay 3 -o %o %u'
          'rsync::/usr/bin/rsync --no-motd -z %u %o'
          'scp::/usr/bin/scp -C %u %o')

# Other common tools:
# /usr/bin/snarf
# /usr/bin/lftpget -c
# /usr/bin/wget

#-- The the package required by makepkg to download VCS sources
#  Format: 'protocol::package'
VCSCLIENTS=('bzr::bzr'
            'git::git'
            'hg::mercurial'
            'svn::subversion')

#########################################################################
# ARCHITECTURE, COMPILE FLAGS
#########################################################################
#
CARCH="x86_64"
CHOST="x86_64-unknown-linux-gnu"

#-- Compiler and Linker Flags
# -march (or -mcpu) builds exclusively for an architecture
# -mtune optimizes for an architecture, but builds for whole processor family
CFLAGS="-march=native -mfpmath=sse -O2 -pipe"
CPPFLAGS="${CFLAGS}"
CXXFLAGS="${CFLAGS}"
LDFLAGS="-Wl,-O1,--sort-common,--as-needed,-z,relro"
#-- Make Flags: change this for DistCC/SMP systems
MAKEFLAGS="-j5"
#-- Debugging flags
DEBUG_CFLAGS=""
DEBUG_CXXFLAGS=""

#########################################################################
# BUILD ENVIRONMENT
#########################################################################
#
# Defaults: BUILDENV=(!distcc color !ccache check !sign)
#  A negated environment option will do the opposite of the comments below.
#
#-- distcc:   Use the Distributed C/C++/ObjC compiler
#-- color:    Colorize output messages
#-- ccache:   Use ccache to cache compilation
#-- check:    Run the check() function if present in the PKGBUILD
#-- sign:     Generate PGP signature file
#
BUILDENV=(fakeroot !distcc color !ccache check !sign)
#
#-- If using DistCC, your MAKEFLAGS will also need modification. In addition,
#-- specify a space-delimited list of hosts running in the DistCC cluster.
#DISTCC_HOSTS=""
#
#-- Specify a directory for package building.
BUILDDIR=/tmp/makepkg

#########################################################################
# GLOBAL PACKAGE OPTIONS
#   These are default values for the options=() settings
#########################################################################
#
# Default: OPTIONS=(strip docs !libtool !staticlibs emptydirs zipman purge !upx                                                 !debug)
#  A negated option will do the opposite of the comments below.
#
#-- strip:      Strip symbols from binaries/libraries
#-- docs:       Save doc directories specified by DOC_DIRS
#-- libtool:    Leave libtool (.la) files in packages
#-- staticlibs: Leave static library (.a) files in packages
#-- emptydirs:  Leave empty directories in packages
#-- zipman:     Compress manual (man and info) pages in MAN_DIRS with gzip
#-- purge:      Remove files specified by PURGE_TARGETS
#-- upx:        Compress binary executable files using UPX
#-- debug:      Add debugging flags as specified in DEBUG_* variables
#
OPTIONS=(strip docs !libtool !staticlibs emptydirs zipman purge !upx !debug)

#-- File integrity checks to use. Valid: md5, sha1, sha256, sha384, sha512
INTEGRITY_CHECK=(md5)
#-- Options to be used when stripping binaries. See `man strip' for details.
STRIP_BINARIES="--strip-all"
#-- Options to be used when stripping shared libraries. See `man strip' for deta                                                ils.
STRIP_SHARED="--strip-unneeded"
#-- Options to be used when stripping static libraries. See `man strip' for deta                                                ils.
STRIP_STATIC="--strip-debug"
#-- Manual (man and info) directories to compress (if zipman is specified)
MAN_DIRS=({usr{,/local}{,/share},opt/*}/{man,info})
#-- Doc directories to remove (if !docs is specified)
DOC_DIRS=(usr/{,local/}{,share/}{doc,gtk-doc} opt/*/{doc,gtk-doc})
#-- Files to be removed from all packages (if purge is specified)
PURGE_TARGETS=(usr/{,share}/info/dir .packlist *.pod)

#########################################################################
# PACKAGE OUTPUT
#########################################################################
#
# Default: put built package and cached source in build directory
#
#-- Destination: specify a fixed directory where all packages will be placed
#PKGDEST=/home/packages
#-- Source cache: specify a fixed directory where source files will be cached
#SRCDEST=/home/sources
#-- Source packages: specify a fixed directory where all src packages will be pl                                                aced
#SRCPKGDEST=/home/srcpackages
#-- Log files: specify a fixed directory where all log files will be placed
#LOGDEST=/home/makepkglogs
#-- Packager: name/email of the person or organization building packages
#PACKAGER="John Doe <john@doe.com>"
#-- Specify a key to use for package signing
#GPGKEY=""

#########################################################################
# COMPRESSION DEFAULTS
#########################################################################
#
COMPRESSGZ=(gzip -c -f -n)
COMPRESSBZ2=(bzip2 -c -f)
COMPRESSXZ=(xz -c -z -)
COMPRESSLRZ=(lrzip -q)
COMPRESSLZO=(lzop -q)
COMPRESSZ=(compress -c -f)

#########################################################################
# EXTENSION DEFAULTS
#########################################################################
#
# WARNING: Do NOT modify these variables unless you know what you are
#          doing.
#
PKGEXT='.pkg.tar.xz'
SRCEXT='.src.tar.gz'

# vim: set ft=sh ts=2 sw=2 et:

Last edited by enihcam (2015-03-06 02:36:10)

Offline

#6 2015-03-06 06:50:10

pb
Member
From: Krakow, PL
Registered: 2014-12-26
Posts: 336
Website

Re: [SOLVED] C(XX)FLAGS does not work for QMAKE based packages.

makepkg also builds Qt apps without C(XX)FLAGS in makepkg.conf. This is a fragment of makepkg of one apps build myself:

make[1]: Wejście do katalogu '/home/pawel/temp/kdestyle-kvantum-plasma5-git/src/Kvantum/Kvantum/style'
g++ -c -pipe -O2 -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong 

My makepkg.conf:

#
# /etc/makepkg.conf
#

#########################################################################
# SOURCE ACQUISITION
#########################################################################
#
#-- The download utilities that makepkg should use to acquire sources
#  Format: 'protocol::agent'
DLAGENTS=('ftp::/usr/bin/curl -fC - --ftp-pasv --retry 3 --retry-delay 3 -o %o %u'
          'http::/usr/bin/curl -fLC - --retry 3 --retry-delay 3 -o %o %u'
          'https::/usr/bin/curl -fLC - --retry 3 --retry-delay 3 -o %o %u'
          'rsync::/usr/bin/rsync --no-motd -z %u %o'
          'scp::/usr/bin/scp -C %u %o')

# Other common tools:
# /usr/bin/snarf
# /usr/bin/lftpget -c
# /usr/bin/wget

#-- The the package required by makepkg to download VCS sources
#  Format: 'protocol::package'
VCSCLIENTS=('bzr::bzr'
            'git::git'
            'hg::mercurial'
            'svn::subversion')

#########################################################################
# ARCHITECTURE, COMPILE FLAGS
#########################################################################
#
CARCH="x86_64"
CHOST="x86_64-unknown-linux-gnu"

#-- Compiler and Linker Flags
# -march (or -mcpu) builds exclusively for an architecture
# -mtune optimizes for an architecture, but builds for whole processor family
CPPFLAGS="-D_FORTIFY_SOURCE=2"
CFLAGS="-march=native -mtune=bdver2 -O2 -pipe -fstack-protector-strong --param=ssp-buffer-size=4"
CXXFLAGS="-march=native -mtune=bdver2 -O2 -pipe -fstack-protector-strong --param=ssp-buffer-size=4"
LDFLAGS="-Wl,-O1,--sort-common,--as-needed,-z,relro"
#-- Make Flags: change this for DistCC/SMP systems
MAKEFLAGS="-j2"
#-- Debugging flags
DEBUG_CFLAGS="-g -fvar-tracking-assignments"
DEBUG_CXXFLAGS="-g -fvar-tracking-assignments"

#########################################################################
# BUILD ENVIRONMENT
#########################################################################
#
# Defaults: BUILDENV=(!distcc color !ccache check !sign)
#  A negated environment option will do the opposite of the comments below.
#
#-- distcc:   Use the Distributed C/C++/ObjC compiler
#-- color:    Colorize output messages
#-- ccache:   Use ccache to cache compilation
#-- check:    Run the check() function if present in the PKGBUILD
#-- sign:     Generate PGP signature file
#
BUILDENV=(!distcc color !ccache check !sign)
#
#-- If using DistCC, your MAKEFLAGS will also need modification. In addition,
#-- specify a space-delimited list of hosts running in the DistCC cluster.
#DISTCC_HOSTS=""
#
#-- Specify a directory for package building.
#BUILDDIR=/tmp/makepkg

#########################################################################
# GLOBAL PACKAGE OPTIONS
#   These are default values for the options=() settings
#########################################################################
#
# Default: OPTIONS=(strip docs !libtool !staticlibs emptydirs zipman purge !upx !debug)
#  A negated option will do the opposite of the comments below.
#
#-- strip:      Strip symbols from binaries/libraries
#-- docs:       Save doc directories specified by DOC_DIRS
#-- libtool:    Leave libtool (.la) files in packages
#-- staticlibs: Leave static library (.a) files in packages
#-- emptydirs:  Leave empty directories in packages
#-- zipman:     Compress manual (man and info) pages in MAN_DIRS with gzip
#-- purge:      Remove files specified by PURGE_TARGETS
#-- upx:        Compress binary executable files using UPX
#-- debug:      Add debugging flags as specified in DEBUG_* variables
#
OPTIONS=(strip docs !libtool !staticlibs emptydirs zipman purge !upx !debug)

#-- File integrity checks to use. Valid: md5, sha1, sha256, sha384, sha512
INTEGRITY_CHECK=(md5)
#-- Options to be used when stripping binaries. See `man strip' for details.
STRIP_BINARIES="--strip-all"
#-- Options to be used when stripping shared libraries. See `man strip' for details.
STRIP_SHARED="--strip-unneeded"
#-- Options to be used when stripping static libraries. See `man strip' for details.
STRIP_STATIC="--strip-debug"
#-- Manual (man and info) directories to compress (if zipman is specified)
MAN_DIRS=({usr{,/local}{,/share},opt/*}/{man,info})
#-- Doc directories to remove (if !docs is specified)
DOC_DIRS=(usr/{,local/}{,share/}{doc,gtk-doc} opt/*/{doc,gtk-doc})
#-- Files to be removed from all packages (if purge is specified)
PURGE_TARGETS=(usr/{,share}/info/dir .packlist *.pod)

#########################################################################
# PACKAGE OUTPUT
#########################################################################
#
# Default: put built package and cached source in build directory
#
#-- Destination: specify a fixed directory where all packages will be placed
#PKGDEST=/home/packages
#-- Source cache: specify a fixed directory where source files will be cached
#SRCDEST=/home/sources
#-- Source packages: specify a fixed directory where all src packages will be placed
#SRCPKGDEST=/home/srcpackages
#-- Log files: specify a fixed directory where all log files will be placed
#LOGDEST=/home/makepkglogs
#-- Packager: name/email of the person or organization building packages
PACKAGER="Paweł Baranowski <pavbaranov@gmail.com>"
#-- Specify a key to use for package signing
#GPGKEY=""

#########################################################################
# COMPRESSION DEFAULTS
#########################################################################
#
COMPRESSGZ=(gzip -c -f -n)
COMPRESSBZ2=(bzip2 -c -f)
COMPRESSXZ=(xz -c -z -)
COMPRESSLRZ=(lrzip -q)
COMPRESSLZO=(lzop -q)
COMPRESSZ=(compress -c -f)

#########################################################################
# EXTENSION DEFAULTS
#########################################################################
#
# WARNING: Do NOT modify these variables unless you know what you are
#          doing.
#
PKGEXT='.pkg.tar.xz'
SRCEXT='.src.tar.gz'

# vim: set ft=sh ts=2 sw=2 et:

By the way, yaourt use makepkg.conf for building packages, see:

# source makepkg configuration
source_makepkg_conf() {
        # From makepkg, try to source the same way
        MAKEPKG_CONF=${MAKEPKG_CONF:-/etc/makepkg.conf}

(it's a part of pkgbuild.sh), then this is not a bug of yaourt.

Offline

#7 2015-03-06 09:00:32

mauritiusdadd
Member
From: Benevento, Italy
Registered: 2013-10-27
Posts: 776

Re: [SOLVED] C(XX)FLAGS does not work for QMAKE based packages.

It not a bug neither of yaourt nor of makepkg. The problem is that qmake automatically set CFLAGS  and CXXFLAGS according to what it thinks should be the right configuration. Since you are compiling a qt4 program on a x86_64 machine, qmake-qt4 most probably uses the configuration file /usr/share/qt4/mkspecs/linux-g++-64/qmake.conf. One of the file sourced in the aforementioned qmake.conf is /usr/share/qt4/mkspecs/common/g++-base.conf which defines the CFLAGS and CXXFLAGS variables that you see in the compilation output.

If you want to use your environment variables instead of the ones generated by qmake, you have two alternatives:

  1. Edit the PKGBUILD and pass the variables QMAKE_CFLAGS_RELEASE and QMAKE_CXXFLAGS_RELEASE to qmake. For example in the case of quiterss:

    # PKGBUILD for quiterss
    
    build() {
      cd "$srcdir/$_pkgname-$pkgver-src"
      qmake-qt4 "$srcdir/$_pkgname-$pkgver-src/$_pkgname.pro" \
        PREFIX=/usr \
        CONFIG+=LINUX_INTEGRATED \
        INSTALL_ROOT_PATH="$pkgdir"\
        QMAKE_CFLAGS_RELEASE="${CFLAGS}"\
        QMAKE_CXXFLAGS_RELEASE="${CXXFLAGS}"
    
      make
    }
  2. Create your custom qmake.conf and define the QMAKESPEC environment variable.

Last edited by mauritiusdadd (2015-03-06 09:21:20)


About me - github

-- When you have eliminated the impossible, whatever remains, however improbable, must be the truth -- Spock | Sherlock Holmes

Offline

#8 2015-03-08 05:47:13

enihcam
Member
From: Internet
Registered: 2009-12-20
Posts: 220

Re: [SOLVED] C(XX)FLAGS does not work for QMAKE based packages.

mauritiusdadd wrote:

It not a bug neither of yaourt nor of makepkg. The problem is that qmake automatically set CFLAGS  and CXXFLAGS according to what it thinks should be the right configuration. Since you are compiling a qt4 program on a x86_64 machine, qmake-qt4 most probably uses the configuration file /usr/share/qt4/mkspecs/linux-g++-64/qmake.conf. One of the file sourced in the aforementioned qmake.conf is /usr/share/qt4/mkspecs/common/g++-base.conf which defines the CFLAGS and CXXFLAGS variables that you see in the compilation output.

If you want to use your environment variables instead of the ones generated by qmake, you have two alternatives:

  1. Edit the PKGBUILD and pass the variables QMAKE_CFLAGS_RELEASE and QMAKE_CXXFLAGS_RELEASE to qmake. For example in the case of quiterss:

    # PKGBUILD for quiterss
    
    build() {
      cd "$srcdir/$_pkgname-$pkgver-src"
      qmake-qt4 "$srcdir/$_pkgname-$pkgver-src/$_pkgname.pro" \
        PREFIX=/usr \
        CONFIG+=LINUX_INTEGRATED \
        INSTALL_ROOT_PATH="$pkgdir"\
        QMAKE_CFLAGS_RELEASE="${CFLAGS}"\
        QMAKE_CXXFLAGS_RELEASE="${CXXFLAGS}"
    
      make
    }
  2. Create your custom qmake.conf and define the QMAKESPEC environment variable.

Thanks. This should be in wiki. smile

Offline

#9 2015-03-08 08:08:38

mauritiusdadd
Member
From: Benevento, Italy
Registered: 2013-10-27
Posts: 776

Re: [SOLVED] C(XX)FLAGS does not work for QMAKE based packages.

enihcam wrote:

Thanks. This should be in wiki. smile

I've added some references and fixed the formatting for you wink
PS: Remember to mark the thread as [SOLVED]


About me - github

-- When you have eliminated the impossible, whatever remains, however improbable, must be the truth -- Spock | Sherlock Holmes

Offline

Board footer

Powered by FluxBB