Merge lp:~loic.molinari/ubuntu-ui-toolkit/uitk-ubuntu-packaging-flags-clean-up into lp:ubuntu-ui-toolkit/staging

Proposed by Loïc Molinari
Status: Merged
Approved by: Loïc Molinari
Approved revision: 2105
Merged at revision: 2119
Proposed branch: lp:~loic.molinari/ubuntu-ui-toolkit/uitk-ubuntu-packaging-flags-clean-up
Merge into: lp:ubuntu-ui-toolkit/staging
Prerequisite: lp:~loic.molinari/ubuntu-ui-toolkit/uitk-ascii-cast-warnings-fix
Diff against target: 161 lines (+56/-24)
6 files modified
.qmake.conf (+2/-2)
debian/rules (+1/-1)
documentation/documentation.pro (+1/-1)
features/ubuntu_enable_testing.prf (+1/-1)
features/ubuntu_qml_plugin.prf (+26/-10)
features/ubuntu_qt_module.prf (+25/-9)
To merge this branch: bzr merge lp:~loic.molinari/ubuntu-ui-toolkit/uitk-ubuntu-packaging-flags-clean-up
Reviewer Review Type Date Requested Status
ubuntu-sdk-build-bot continuous-integration Approve
Benjamin Zeller Approve
Zsombor Egri Approve
Review via email: mp+305843@code.launchpad.net

Commit message

Cleaned up qmake Ubuntu packaging variables.

The qtbase packaging for Ubuntu exports the CFLAGS, CXXFLAGS and LFLAGS variables in the environment before running configure so that the qtbase shared libraries can be compiled with the required distribution defined compiler flags. That is fine (though I guess that could be handled better at the qtbase packaging level with maybe a dedicated prf) but it results in qt_build_config.prf defining the QMAKE_CFLAGS, QMAKE_CXXFLAGS and QMAKE_LFLAGS variables with these distribution specific flags. Since we load this prf, these variables end up being defined when building the toolkit for development purpose. This is problematic because -O2 and -g are always defined (whatever the debug or release config chosen by the developer), also these are GCC specific flags which makes our build break with other compilers. This is also ugly because preprocessor defines are directly set in the QMAKE_C*FLAGS. In order to workaround these issues, we unset these variables and set the different flags apart from -g and -O2 in the right qmake variables. This allows to keep compiling with the Debian flags but in a more flexible way. For the Debian packaging, we keep the former behaviour by simply passing the debian_build config.

Description of the change

Cleaned up qmake Ubuntu packaging variables.

The qtbase packaging for Ubuntu exports the CFLAGS, CXXFLAGS and LFLAGS variables in the environment before running configure so that the qtbase shared libraries can be compiled with the required distribution defined compiler flags. That is fine (though I guess that could be handled better at the qtbase packaging level with maybe a dedicated prf) but it results in qt_build_config.prf defining the QMAKE_CFLAGS, QMAKE_CXXFLAGS and QMAKE_LFLAGS variables with these distribution specific flags. Since we load this prf, these variables end up being defined when building the toolkit for development purpose. This is problematic because -O2 and -g are always defined (whatever the debug or release config chosen by the developer), also these are GCC specific flags which makes our build break with other compilers. This is also ugly because preprocessor defines are directly set in the QMAKE_C*FLAGS. In order to workaround these issues, we unset these variables and set the different flags apart from -g and -O2 in the right qmake variables. This allows to keep compiling with the Debian flags but in a more flexible way. For the Debian packaging, we keep the former behaviour by simply passing the debian_build config.

Here are the flags for the toolkit libs:

qmake CONFIG=release
CXXFLAGS = -fstack-protector -Werror -O2 -std=c++0x -fvisibility=hidden -fvisibility-inlines-hidden -pthread -fno-exceptions -Wall -W -Wsuggest-override -Wdate-time -Wformat -Werror=format-security -D_REENTRANT -fPIC $(DEFINES)
LFLAGS = -Wl,--no-undefined -Wl,-O1 -fuse-ld=gold -Wl,--enable-new-dtags -shared -Wl,-z,relro -Wl,-Bsymbolic-functions -Wl,-soname,libUbuntuToolkit.so.5

qmake CONFIG+=debug
CXXFLAGS = -fstack-protector -Werror -g -std=c++0x -fvisibility=hidden -fvisibility-inlines-hidden -pthread -fno-exceptions -Wall -W -Wsuggest-override -Wdate-time -Wformat -Werror=format-security -D_REENTRANT -fPIC $(DEFINES)
LFLAGS = -Wl,--no-undefined -fuse-ld=gold -Wl,--enable-new-dtags -shared -Wl,-z,relro -Wl,-Bsymbolic-functions -Wl,-soname,libUbuntuToolkit.so.5

qmake CONFIG+=debian_build
CXXFLAGS = -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -Werror -O2 -std=c++0x -fvisibility=hidden -fvisibility-inlines-hidden -pthread -fno-exceptions -Wall -W -Wsuggest-override -D_REENTRANT -fPIC $(DEFINES)
LFLAGS = -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,--as-needed -Wl,--no-undefined -Wl,-O1 -fuse-ld=gold -Wl,--enable-new-dtags -shared -Wl,-Bsymbolic-functions -Wl,-soname,libUbuntuToolkit.so.5

To post a comment you must log in.
Revision history for this message
Loïc Molinari (loic.molinari) wrote :

I've got a MR almost ready to share the common stuff for C++ libs and QML plugins.

Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Loïc Molinari (loic.molinari) wrote :
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Zsombor Egri (zsombi) wrote :

Looks good to me, let's see Benjamin's verdict.

review: Approve
Revision history for this message
Benjamin Zeller (zeller-benjamin) wrote :

Nice work! Looks good to me too!

review: Approve
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.qmake.conf'
2--- .qmake.conf 2016-09-13 14:01:32 +0000
3+++ .qmake.conf 2016-09-15 14:57:04 +0000
4@@ -14,11 +14,11 @@
5 ROOT_BUILD_DIR=$$shadowed($$PWD)
6
7 exists($$PWD/../qt.pro) {
8- CONFIG += build_with_qt
9+ CONFIG += qt_submodule_build
10 } else {
11 # When built as a Qt submodule, -Wsuggest-override breaks the build. That's
12 # fixed in Qt 5.6. See https://codereview.qt-project.org/#/c/169969/
13- gcc:greaterThan(QT_GCC_MAJOR_VERSION, 4): QMAKE_CXXFLAGS += -Wsuggest-override
14+ gcc:greaterThan(QT_GCC_MAJOR_VERSION, 4): QMAKE_CXXFLAGS_WARN_ON += -Wsuggest-override
15 }
16
17 # FIXME: Fix bug 1606247 and enable the UbuntuToolkit namespace.
18
19=== modified file 'debian/rules'
20--- debian/rules 2016-09-15 14:51:50 +0000
21+++ debian/rules 2016-09-15 14:57:04 +0000
22@@ -16,7 +16,7 @@
23 testskip_series := yakkety xenial
24
25 override_dh_auto_configure:
26- qmake -r
27+ qmake -r CONFIG+=debian_build
28
29 %:
30 dh $@ --parallel
31
32=== modified file 'documentation/documentation.pro'
33--- documentation/documentation.pro 2015-08-13 09:20:05 +0000
34+++ documentation/documentation.pro 2016-09-15 14:57:04 +0000
35@@ -17,7 +17,7 @@
36 generate_docs.commands = cd $$ROOT_SOURCE_DIR; SRC=$$ROOT_SOURCE_DIR/documentation BLD=$$ROOT_BUILD_DIR/documentation $$ROOT_SOURCE_DIR/documentation/docs.sh \'$$QDOC\' \'$$QHELPGENERATOR\' $$DOC_PATH
37
38 #install the online docs only when building outside of Qt
39-!build_with_qt{
40+!qt_submodule_build{
41 install_docs.files = $$shadowed($$ROOT_SOURCE_DIR)/documentation/html
42 install_docs.path = /usr/share/ubuntu-ui-toolkit/doc
43 install_docs.CONFIG += no_check_exist directory no_build
44
45=== modified file 'features/ubuntu_enable_testing.prf'
46--- features/ubuntu_enable_testing.prf 2015-08-13 09:20:05 +0000
47+++ features/ubuntu_enable_testing.prf 2016-09-15 14:57:04 +0000
48@@ -1,6 +1,6 @@
49 instbase = $$ROOT_BUILD_DIR/qml
50
51-!build_with_qt {
52+!qt_submodule_build {
53 # These bizarre rules copy the files to the build directory
54
55 defineReplace(qmlModStripSrcDir) {
56
57=== modified file 'features/ubuntu_qml_plugin.prf'
58--- features/ubuntu_qml_plugin.prf 2016-06-17 13:42:23 +0000
59+++ features/ubuntu_qml_plugin.prf 2016-09-15 14:57:04 +0000
60@@ -1,3 +1,28 @@
61+# The qtbase packaging for Ubuntu exports the CFLAGS, CXXFLAGS and LFLAGS
62+# variables in the environment before running configure so that the qtbase
63+# shared libraries can be compiled with the required distribution defined
64+# compiler flags. That is fine (though I guess that could be handled better at
65+# the qtbase packaging level with maybe a dedicated prf) but it results in
66+# qt_build_config.prf defining the QMAKE_CFLAGS, QMAKE_CXXFLAGS and QMAKE_LFLAGS
67+# variables with these distribution specific flags. Since we load this prf,
68+# these variables end up being defined when building the toolkit for development
69+# purpose. This is problematic because -O2 and -g are always defined (whatever
70+# the debug or release config chosen by the developer), also these are GCC
71+# specific flags which makes our build break with other compilers. This is also
72+# ugly because preprocessor defines are directly set in the QMAKE_C*FLAGS. In
73+# order to workaround these issues, we unset these variables and set the
74+# different flags apart from -g and -O2 in the right qmake variables. This
75+# allows to keep compiling with the Debian flags but in a more flexible way.
76+gcc:!qt_submodule_build:!debian_build {
77+ QMAKE_CFLAGS = -fstack-protector
78+ QMAKE_CXXFLAGS = -fstack-protector
79+ QMAKE_LFLAGS =
80+ QMAKE_CXXFLAGS_WARN_ON += -Wdate-time -Wformat -Werror=format-security
81+ QMAKE_LFLAGS_SHLIB += -Wl,-z,relro
82+ DEFINES += _FORTIFY_SOURCE=2
83+ unix:!contains(QT_CONFIG, reduce_relocations): CONFIG += bsymbolic_functions
84+}
85+
86 load(qml_plugin)
87 CONFIG -= hide_symbols
88
89@@ -5,7 +30,7 @@
90
91 #hacky hacks to build the qmltypes
92
93-!build_with_qt{
94+!qt_submodule_build {
95 #should be already set by the qml_plugin.prf, but lets be safe
96 isEmpty(IMPORT_VERSION): error("Must set IMPORT_VERSION")
97
98@@ -71,15 +96,6 @@
99 QMAKE_EXTRA_TARGETS += autobld_qmltypes
100 }
101
102-# when building against the system Qt we pick up the CXX_FLAGS for a release build
103-# reset them to the default debug build flags
104-!build_with_qt: {
105- CONFIG(debug, debug|release) {
106- QMAKE_CFLAGS = $$QMAKE_CFLAGS_DEBUG
107- QMAKE_CXXFLAGS = $$QMAKE_CXXFLAGS_DEBUG
108- }
109-}
110-
111 QMAKE_CXXFLAGS += -Werror
112
113 #do not warn for deprecated declarations
114
115=== modified file 'features/ubuntu_qt_module.prf'
116--- features/ubuntu_qt_module.prf 2016-09-12 08:18:53 +0000
117+++ features/ubuntu_qt_module.prf 2016-09-15 14:57:04 +0000
118@@ -1,3 +1,28 @@
119+# The qtbase packaging for Ubuntu exports the CFLAGS, CXXFLAGS and LFLAGS
120+# variables in the environment before running configure so that the qtbase
121+# shared libraries can be compiled with the required distribution defined
122+# compiler flags. That is fine (though I guess that could be handled better at
123+# the qtbase packaging level with maybe a dedicated prf) but it results in
124+# qt_build_config.prf defining the QMAKE_CFLAGS, QMAKE_CXXFLAGS and QMAKE_LFLAGS
125+# variables with these distribution specific flags. Since we load this prf,
126+# these variables end up being defined when building the toolkit for development
127+# purpose. This is problematic because -O2 and -g are always defined (whatever
128+# the debug or release config chosen by the developer), also these are GCC
129+# specific flags which makes our build break with other compilers. This is also
130+# ugly because preprocessor defines are directly set in the QMAKE_C*FLAGS. In
131+# order to workaround these issues, we unset these variables and set the
132+# different flags apart from -g and -O2 in the right qmake variables. This
133+# allows to keep compiling with the Debian flags but in a more flexible way.
134+gcc:!qt_submodule_build:!debian_build {
135+ QMAKE_CFLAGS = -fstack-protector
136+ QMAKE_CXXFLAGS = -fstack-protector
137+ QMAKE_LFLAGS =
138+ QMAKE_CXXFLAGS_WARN_ON += -Wdate-time -Wformat -Werror=format-security
139+ QMAKE_LFLAGS_SHLIB += -Wl,-z,relro
140+ DEFINES += _FORTIFY_SOURCE=2
141+ unix:!contains(QT_CONFIG, reduce_relocations): CONFIG += bsymbolic_functions
142+}
143+
144 # Enables the copy of private and public headers to an include directory at the
145 # root of the sources before compilation and the copy of the compiled libraries
146 # after compilation. Must be set before loading qt_module.
147@@ -11,15 +36,6 @@
148 # Common config options.
149 CONFIG += dll no_keywords c++11
150
151-# When building against the system Qt we pick up the CXX_FLAGS for a release
152-# build reset them to the default debug build flags.
153-!build_with_qt: {
154- CONFIG(debug, debug|release) {
155- QMAKE_CFLAGS = $$QMAKE_CFLAGS_DEBUG
156- QMAKE_CXXFLAGS = $$QMAKE_CXXFLAGS_DEBUG
157- }
158-}
159-
160 # Make all warnings into errors.
161 QMAKE_CXXFLAGS += -Werror
162

Subscribers

People subscribed via source and target branches