tech-pkg archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: why does devel/cmake's Makefile subst's out compiler optimization?
On Fri, Apr 06, 2018 at 10:32:25PM +0200, Thomas Klausner wrote:
> That sounds reasonable to me.
> Do you want to add patches for gcc and clang and get rid of the SUBST?
sure, but can you review the changes first? i don't want
to break anything.
It turns out that both clang and gcc use the GNU.cmake file.
(the share/cmake-3.11/Modules/Compiler/Clang.cmake file
does a "include(Compiler/GNU)" and uses the values from there).
so the diff to devel/cmake removes the SUBST and adds a checksum
for the new patch file for GNU.cmake. I also had to add
${WRKSRC}/Modules/Compiler/*.orig to the pre-configure removal
of ".orig" files, otherwise "make install" fails due to the orig
file not being in the PLIST file:
Index: Makefile
===================================================================
RCS file: /cvsroot/pkgsrc/devel/cmake/Makefile,v
retrieving revision 1.141
diff -u -r1.141 Makefile
--- Makefile 2 Apr 2018 19:36:44 -0000 1.141
+++ Makefile 7 Apr 2018 21:03:16 -0000
@@ -51,14 +51,8 @@
SUBST_FILES.cmake+= Modules/Platform/UnixPaths.cmake
SUBST_VARS.cmake= LOCALBASE X11BASE
-SUBST_CLASSES+= flags
-SUBST_STAGE.flags= pre-configure
-SUBST_MESSAGE.flags= Fixing compiler flags.
-SUBST_FILES.flags= Modules/Compiler/*.cmake
-SUBST_SED.flags= -e 's,-O.,,'
-
pre-configure:
- ${RM} -f ${WRKSRC}/Modules/*.orig ${WRKSRC}/Modules/Platform/*.orig
+ ${RM} -f ${WRKSRC}/Modules/*.orig ${WRKSRC}/Modules/Compiler/*.orig ${WRKSRC}/Modules/Platform/*.orig
${LN} -f ${WRKSRC}/Modules/Platform/OpenBSD.cmake ${WRKSRC}/Modules/Platform/MirBSD.cmake
.for lang in C CXX Fortran
${LN} -f ${WRKSRC}/Modules/Platform/SunOS-GNU-${lang}.cmake \
Index: distinfo
===================================================================
RCS file: /cvsroot/pkgsrc/devel/cmake/distinfo,v
retrieving revision 1.115
diff -u -r1.115 distinfo
--- distinfo 2 Apr 2018 19:36:44 -0000 1.115
+++ distinfo 7 Apr 2018 21:03:16 -0000
@@ -5,6 +5,7 @@
SHA512 (cmake-3.11.0.tar.gz) = 03b058483d236d4f4427c93cc41af77068c243fc4b6f24aeaf2daf97af215bc664bc1b733195463af4cfc94ec70076710f425661859d752ddf3b9610adca9834
Size (cmake-3.11.0.tar.gz) = 7948287 bytes
SHA1 (patch-CMakeLists.txt) = a0b03f2fad5ea174095c4fe52cea67d94cf46e2d
+SHA1 (patch-Modules_Compiler_GNU.cmake) = e091c53ac3f3a6cd811119d3231563df32e76bf9
SHA1 (patch-Modules_FindCurses.cmake) = 09fcd7adfbc2dfc2cd8af4e047d870a5243d77dc
SHA1 (patch-Modules_FindPythonInterp.cmake) = d1b39bdcd654f2a4fc63463cd20de656cce3cf8f
SHA1 (patch-Modules_FindPythonLibs.cmake) = b5cedc6a2354beaf08e06d416c150154a7dc1f05
the "patch-Modules_Compiler_GNU.cmake" file adds code to turn off
the opt flags if CMAKE_BOOTSTRAP or CMAKE_PKGSRC_BUILD_FLAGS is
set. i added CMAKE_BOOTSTRAP so that this CFLAG change would
work even when you are building devel/cmake itself (the bootstrap
case):
$NetBSD$
Add CMAKE_PKGSRC_BUILD_FLAGS to allow pkgsrc-based builds to set
compiler optimizer flags (overrides CMAKE_BUILD_TYPE). Also enabled
for CMAKE_BOOTSTRAP so it is applied to the build of cmake itself.
--- Modules/Compiler/GNU.cmake.orig 2018-03-16 07:16:31.000000000 -0400
+++ Modules/Compiler/GNU.cmake 2018-04-07 16:23:51.000000000 -0400
@@ -39,9 +39,15 @@
# Initial configuration flags.
string(APPEND CMAKE_${lang}_FLAGS_INIT " ")
string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " -g")
- string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " -Os -DNDEBUG")
- string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -O3 -DNDEBUG")
- string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -O2 -g -DNDEBUG")
+ if(CMAKE_BOOTSTRAP OR CMAKE_PKGSRC_BUILD_FLAGS)
+ string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " -DNDEBUG")
+ string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -DNDEBUG")
+ string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -g -DNDEBUG")
+ else()
+ string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " -Os -DNDEBUG")
+ string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -O3 -DNDEBUG")
+ string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -O2 -g -DNDEBUG")
+ endif()
set(CMAKE_${lang}_CREATE_PREPROCESSED_SOURCE "<CMAKE_${lang}_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>")
set(CMAKE_${lang}_CREATE_ASSEMBLY_SOURCE "<CMAKE_${lang}_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -S <SOURCE> -o <ASSEMBLY_SOURCE>")
if(NOT APPLE OR NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 4) # work around #4462
finally, the mk/configure diff adds -DCMAKE_PKGSRC_BUILD_FLAGS:BOOL=TRUE
to the pkgsrc CMAKE_ARGS to enable this feature for packages that
pkgsrc builds with cmake. I added a way to disable this for packages
that don't compile files (i.e. ones that would have
"project (foo NONE)" rather than "project (foo C CXX)" in
their CMakeLists.txt files) in order to avoid a harmless warning:
Manually-specified variables were not used by the project"
about the CMAKE_PKGSRC_BUILD_FLAGS variable:
Index: cmake.mk
===================================================================
RCS file: /cvsroot/pkgsrc/mk/configure/cmake.mk,v
retrieving revision 1.15
diff -u -r1.15 cmake.mk
--- cmake.mk 27 Dec 2017 18:56:27 -0000 1.15
+++ cmake.mk 7 Apr 2018 21:14:10 -0000
@@ -15,6 +15,14 @@
# variable is adjusted to include the path from the pkgsrc wrappers.
# The file ${WRKSRC}/CMakeLists.txt is always appended to this list.
#
+# CMAKE_PKGSRC_BUILD_FLAGS
+# If set to yes, disable compiler optimization flags associated
+# with the CMAKE_BUILD_TYPE setting (for pkgsrc these come in from
+# the user via variables like CFLAGS). The default is yes, but you can
+# set it to no for pkgsrc packages that do not use a compiler to avoid
+# cmake "Manually-specified variables were not used by the project"
+# warnings associated with this variable.
+#
# CMAKE_PREFIX_PATH
# A list of directories to add the CMAKE_PREFIX_PATH cmake variable.
# If a package installs its contents in ${PREFIX}/package instead of
@@ -39,6 +47,9 @@
CMAKE_ARGS+= -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX}
CMAKE_ARGS+= -DCMAKE_MODULE_PATH:PATH=${_CMAKE_DIR}
+.if empty(CMAKE_PKGSRC_BUILD_FLAGS:M[nN][oO])
+CMAKE_ARGS+= -DCMAKE_PKGSRC_BUILD_FLAGS:BOOL=TRUE
+.endif
.if ${OPSYS} != "Darwin"
CMAKE_ARGS+= -DCMAKE_SKIP_RPATH:BOOL=TRUE
.else
i tested these with a test pkgsrc build on my laptop and the
changes seem to work.
do they look ok?
chuck
Home |
Main Index |
Thread Index |
Old Index