Here's how compiler being called: [ 99% 732/733] ccache /usr/local/libexec/ccache/c++ -DNETWORK_DIAG -DQT_CORE_LIB -DQT_EXPLICIT_QFILE_CONSTRUCTION_FROM_PATH -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_NO_AS_CONST=1 -DQT_NO_CONTEXTLESS_CONNECT=1 -DQT_NO_DEBUG -DQT_NO_EXCEPTIONS -DQT_NO_FOREACH -DQT_NO_FOREACH=1 -DQT_NO_JAVA_STYLE_ITERATORS -DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT -DQT_NO_QASCONST -DQT_NO_QEXCHANGE -DQT_NO_QSNPRINTF -DQT_OPENGL_LIB -DQT_WIDGETS_LIB -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_FAST -I/wrkdirs/usr/ports/devel/qt6-tools/work/.build/src/qtdiag/qtdiag_autogen/include -I/wrkdirs/usr/ports/devel/qt6-tools/work/qttools-everywhere-src-6.9.1/src/qtdiag -I/wrkdirs/usr/ports/devel/qt6-tools/work/.build/src/qtdiag -isystem /usr/local/include/qt6/QtCore -isystem /usr/local/include/qt6 -isystem /usr/local/lib/qt6/mkspecs/freebsd-clang -isystem /usr/local/include/qt6/QtCore/6.9.1 -isystem /usr/local/include/qt6/QtCore/6.9.1/QtCore -isystem /usr/local/include/qt6/QtOpenGL -isystem /usr/local/include/qt6/QtGui -isystem /usr/local/include -isystem /usr/local/include/qt6/QtGui/6.9.1 -isystem /usr/local/include/qt6/QtGui/6.9.1/QtGui -isystem /usr/local/include/qt6/QtWidgets -isystem /usr/local/include/qt6/QtNetwork -O3 -pipe -march=skylake -fstack-protector-strong -fno-strict-aliasing -pipe -march=skylake -fstack-protector-strong -fno-strict-aliasing -DNDEBUG -O2 -std=gnu++17 -fPIE -fvisibility=hidden -fvisibility-inlines-hidden -Wall -Wextra -fPIC -pthread -fcf-protection=full -ftrivial-auto-var-init=pattern -fstack-protector-strong -fno-exceptions -MD -MT src/qtdiag/CMakeFiles/qtdiag.dir/qtdiag.cpp.o -MF src/qtdiag/CMakeFiles/qtdiag.dir/qtdiag.cpp.o.d -o src/qtdiag/CMakeFiles/qtdiag.dir/qtdiag.cpp.o -c /wrkdirs/usr/ports/devel/qt6-tools/work/qttools-everywhere-src-6.9.1/src/qtdiag/qtdiag.cpp make.conf cut: CPUTYPE?=skylake CFLAGS=-O3 -pipe Actual invocation: <...> -O3 -pipe -march=skylake <...> -O2 -std=gnu++17 <...> Thus, latter '-O2' overrides my CFLAGS. According to section 13.9 of Porter's Handbook [0], port MUST respect CFLAGS, especially optimization level: > The port must respect CFLAGS. What we mean by this is that the port must not set the value of this variable absolutely, overriding the existing value. > Remove optimization flags from the third party Makefiles. The system CFLAGS contains system-wide optimization flags. [0]: https://docs.freebsd.org/en/books/porters-handbook/book/#dads-cflags
(Full poudriere build log available upon request.)
Thank you for your report! Patches are welcome!
Port still violates section 13.9 of Porter's Handbook and it has been officially acknowledged, please don't close this PR until it will be fixed.
This isn't a ports thing, this is an upstream-thing: /usr/local/lib/cmake/Qt6/QtCompilerOptimization.cmake sets up optimization flags, and those optimization flags (-O2 for a "OPTIMIZE" build, and -O3 for a "OPTIMIZE_FULL" build) are appended somewhere, which is why -O2 comes after the CFLAGS from your make.conf. You can test that by editing the file to temporarily add, say, "-DBOGUS" there. As Max said, feel free to provide patches, preferably directly to upstream. If you make the port build with **no** CMake build-type (I believe that by default it builds as "Release"), e.g. at port-level use "make CMAKE_BUILD_TYPE=Bogus", then you will get the flags for Bogus, which are blank. At ports-level, though, we're not interested in fighting upstream for this.