Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[qt5-base] Remove duplicate flags qt #31634

Merged
merged 8 commits into from
Jun 13, 2023

Conversation

JavierMatosD
Copy link
Contributor

@JavierMatosD JavierMatosD commented May 25, 2023

Attempts to resolve this #28835 by removing duplicate flags from qmodule.pri

Hi @daschuer, I don't have a way to repro your issue, but please feel free to try out these changes.

@Adela0814 Adela0814 added category:port-bug The issue is with a library, which is something the port should already support category:community-triplet A PR or issue related to community triplets not officially validated by the vcpkg team. labels May 26, 2023
@daschuer
Copy link
Contributor

This idea is interesting. I have tested the build here:
You can download the log files and artefacts at the bottom of the side:
https://github.com/daschuer/vcpkg/actions/runs/5131095086

The qmodule.pri file still contains a lot more redundant information collected during the qt5-base build:

EXTRA_INCLUDEPATH += $$[QT_INSTALL_HEADERS]/../ $$[QT_INSTALL_HEADERS]
EXTRA_LIBDIR += $$[QT_INSTALL_LIBS] $$[QT_INSTALL_LIBS]/manual-link
!host_build|!cross_compile {
    QMAKE_LIBS_PRIVATE+=$$[QT_INSTALL_LIBS]/libbz2.a
    QMAKE_LIBS_PRIVATE+=$$[QT_INSTALL_LIBS]/libpng16.a $$[QT_INSTALL_LIBS]/libz.a
    QMAKE_LIBS_PRIVATE+=$$[QT_INSTALL_LIBS]/libzstd.a
    QMAKE_CC=cc
    QMAKE_CXX=c++
    QMAKE_AR=ar
    QMAKE_RANLIB=ranlib
    QMAKE_STRIP=strip
    QMAKE_NM=nm
    QMAKE_RC=
    QMAKE_MT=
    QMAKE_AR+=qc
    QMAKE_LINK=c++
    QMAKE_LINK_SHLIB=c++
    QMAKE_LINK_C=cc
    QMAKE_LINK_C_SHLIB=cc
    QMAKE_CFLAGS_RELEASE+=-fPIC -O3 -DNDEBUG  -isysroot "/Applications/Xcode_12.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk" -arch x86_64 -mmacosx-version-min=10.14
    QMAKE_CXXFLAGS_RELEASE=
    QMAKE_LFLAGS+=-isysroot "/Applications/Xcode_12.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk" -arch x86_64 -mmacosx-version-min=10.14
    QMAKE_LFLAGS_SHLIB+=-isysroot "/Applications/Xcode_12.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk" -arch x86_64 -mmacosx-version-min=10.14
    QMAKE_LFLAGS_PLUGIN+=-isysroot "/Applications/Xcode_12.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk" -arch x86_64 -mmacosx-version-min=10.14
}
QT_CPU_FEATURES.x86_64 = cx16 mmx sse sse2 sse3 ssse3 sse4.1
QT.global_private.enabled_features = sse2 alloca_h alloca avx2 dbus dlopen gc_binaries gui network reduce_exports sql system-zlib testlib widgets xml zstd
QT.global_private.disabled_features = alloca_malloc_h android-style-assets private_tests dbus-linked intelcet libudev posix_fallocate reduce_relocations release_tools relocatable stack-protector-strong
QMAKE_LIBS_LIBDL = 
QT_COORD_TYPE = double
QMAKE_LIBS_ZLIB = $$[QT_INSTALL_LIBS]/libz.a
QMAKE_LIBS_ZSTD = -lzstd
CONFIG += sse2 aesni sse3 ssse3 sse4_1 sse4_2 avx avx2 avx512f avx512bw avx512cd avx512dq avx512er avx512ifma avx512pf avx512vbmi avx512vl compile_examples f16c largefile precompile_header rdrnd rdseed shani x86SimdAlways
QT_BUILD_PARTS += libs tools
QT_HOST_CFLAGS_DBUS += 

@daschuer
Copy link
Contributor

All these flags are passed again from vcpkg here:

cd src/ && ( test -e Makefile || /Users/runner/mixxx-vcpkg/installed/x64-osx-min1014/tools/qt5/bin/qmake -o Makefile /Users/runner/mixxx-vcpkg/buildtrees/qt5-svg/src/5.15.9-d2e6ed071f.clean/src/src.pro 
CONFIG-=debug CONFIG+=release QMAKE_CC=cc QMAKE_CXX=c++ QMAKE_AR=ar QMAKE_RANLIB=ranlib QMAKE_STRIP=strip QMAKE_NM=nm QMAKE_RC= QMAKE_MT= QMAKE_AR+=qc QMAKE_LINK=c++ QMAKE_LINK_SHLIB=c++ QMAKE_LINK_C=cc QMAKE_LINK_C_SHLIB=cc 
'QMAKE_CFLAGS_RELEASE+=-fPIC -isysroot /Applications/Xcode_12.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk -mmacosx-version-min=10.14  -O3 -DNDEBUG' 
'QMAKE_CXXFLAGS_RELEASE+=-fPIC -isysroot /Applications/Xcode_12.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk -mmacosx-version-min=10.14  -O3 -DNDEBUG' 
'QMAKE_LFLAGS+=-isysroot /Applications/Xcode_12.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk -mmacosx-version-min=10.14' 
'QMAKE_LFLAGS_SHLIB+=-isysroot /Applications/Xcode_12.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk -mmacosx-version-min=10.14' 
'QMAKE_LFLAGS_PLUGIN+=-isysroot /Applications/Xcode_12.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk -mmacosx-version-min=10.14' 
CONFIG-=shared 'CONFIG*=static' -qtconf /Users/runner/mixxx-vcpkg/buildtrees/qt5-svg/x64-osx-min1014-rel/qt.conf ) && /Applications/Xcode_12.4.app/Contents/Developer/usr/bin/make -f Makefile 

@daschuer
Copy link
Contributor

But there are still duplicates like -mmacosx-version-min=10.14 while I am afraid that the -arch x86_64 will be lost after fully applying you approach. I think my original concern applies that it is not reasonable to hack around a working build system that is in unfortunately concurrent to the vcpkg approach. Instead I prefer to adust vcpkg to respect that.

This would allow cross building with vcpkg which is supported by QT but broken: https://github.com/daschuer/vcpkg/actions/runs/5131095086/jobs/9230730990

See a resulting compiler invocations using this branch:

c++ -c -include.pch/Qt5Svg_x86_64.pch/c++_x86_64 -pipe -stdlib=libc++ -fPIC -isysroot /Applications/Xcode_12.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk -mmacosx-version-min=10.14 -O3 -DNDEBUG -fPIC -std=c++1z -fapplication-extension  -arch x86_64 -isysroot /Applications/Xcode_12.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk -mmacosx-version-min=10.14 -fvisibility=hidden -fvisibility-inlines-hidden -fno-exceptions -Wall -Wextra -Winconsistent-missing-override -Wobjc-interface-ivars -Wobjc-method-access -Wobjc-multiple-method-names -Werror=unguarded-availability -Werror=unguarded-availability-new -Werror=unsupported-availability-guard -ffunction-sections -fdata-sections -DQT_NO_LINKED_LIST -DQT_NO_FOREACH -DQT_NO_USING_NAMESPACE -DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT -DGL_SILENCE_DEPRECATION -DQT_BUILD_SVG_LIB -DQT_BUILDING_QT -DQT_NO_CAST_TO_ASCII -DQT_ASCII_CAST_WARNINGS -DQT_MOC_COMPAT -DQT_USE_QSTRINGBUILDER -DQT_DEPRECATED_WARNINGS -DQT_DISABLE_DEPRECATED_BEFORE=0x050000 -DQT_DEPRECATED_WARNINGS_SINCE=0x060000 -DQT_NO_EXCEPTIONS -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I/Users/runner/mixxx-vcpkg/buildtrees/qt5-svg/src/5.15.9-d2e6ed071f.clean/src/svg -I. -I/Users/runner/mixxx-vcpkg/buildtrees/qt5-svg/src/5.15.9-d2e6ed071f.clean/include -I/Users/runner/mixxx-vcpkg/buildtrees/qt5-svg/src/5.15.9-d2e6ed071f.clean/include/QtSvg -I../../include -I../../include/QtSvg -I/Users/runner/mixxx-vcpkg/buildtrees/qt5-svg/src/5.15.9-d2e6ed071f.clean/include/QtSvg/5.15.9 -I/Users/runner/mixxx-vcpkg/buildtrees/qt5-svg/src/5.15.9-d2e6ed071f.clean/include/QtSvg/5.15.9/QtSvg -I/Users/runner/mixxx-vcpkg/installed/x64-osx-min1014/include/qt5/QtWidgets/5.15.9 -I/Users/runner/mixxx-vcpkg/installed/x64-osx-min1014/include/qt5/QtWidgets/5.15.9/QtWidgets -I/Users/runner/mixxx-vcpkg/installed/x64-osx-min1014/include/qt5/QtGui/5.15.9 -I/Users/runner/mixxx-vcpkg/installed/x64-osx-min1014/include/qt5/QtGui/5.15.9/QtGui -I/Users/runner/mixxx-vcpkg/installed/x64-osx-min1014/include/qt5/QtCore/5.15.9 -I/Users/runner/mixxx-vcpkg/installed/x64-osx-min1014/include/qt5/QtCore/5.15.9/QtCore -I/Users/runner/mixxx-vcpkg/installed/x64-osx-min1014/include/qt5 -I/Users/runner/mixxx-vcpkg/installed/x64-osx-min1014/include/qt5/QtWidgets -I/Users/runner/mixxx-vcpkg/installed/x64-osx-min1014/include/qt5/QtGui -I/Users/runner/mixxx-vcpkg/installed/x64-osx-min1014/include/qt5/QtCore -I.moc -I/Applications/Xcode_12.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/OpenGL.framework/Headers -I/Applications/Xcode_12.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/AGL.framework/Headers -I/Users/runner/mixxx-vcpkg/installed/x64-osx-min1014/include -I/Users/runner/mixxx-vcpkg/installed/x64-osx-min1014/include/qt5 -I/Users/runner/mixxx-vcpkg/installed/x64-osx-min1014/tools/qt5/mkspecs/macx-clang -o .obj/qsvggraphics.o /Users/runner/mixxx-vcpkg/buildtrees/qt5-svg/src/5.15.9-d2e6ed071f.clean/src/svg/qsvggraphics.cpp

# Remove duplicate flags from qmodule.pri issue -> https://github.com/microsoft/vcpkg/issues/28835
if(EXISTS "${CURRENT_INSTALLED_DIR}/tools/qt5/mkspecs/qmodule.pri")
file(READ "${CURRENT_INSTALLED_DIR}/tools/qt5/mkspecs/qmodule.pri" QMODULE_PRI_CONTENT)
string(REGEX REPLACE "QMAKE_CXXFLAGS_RELEASE\\+=[^\n]*\n" "QMAKE_CXXFLAGS_RELEASE=\n" QMODULE_PRI_CONTENT ${QMODULE_PRI_CONTENT})
Copy link
Member

@BillyONeal BillyONeal May 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this file always \n or could it be \r\n?

Should we be asserting that this is at the beginning of a line?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

string(REGEX REPLACE "^QMAKE_CXXFLAGS_RELEASE\\+=[^\r\n]*[\r\n]" "QMAKE_CXXFLAGS_RELEASE=\r\n" QMODULE_PRI_CONTENT ${QMODULE_PRI_CONTENT})

?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't think you need to defend against it, just curious if we checked on a \r\n platform

@BillyONeal
Copy link
Member

I think my original concern applies that it is not reasonable to hack around a working build system that is in unfortunately concurrent to the vcpkg approach. Instead I prefer to adust vcpkg to respect that.

It's also not reasonable to just ignore a user setting. If the user's triplet says 'build with these flags', qt needs to be built with those flags. #29052 breaks an explicitly documented knob.

@daschuer
Copy link
Contributor

It's also not reasonable to just ignore a user setting.

Yes, of cause. #29052 does not break it. The triplet settings are respected and verified in the build process of qt5-base.

The issue is that Qt stores the results in qmodule.pri and re-uses if for other modules. If we, like proposed here delete the stored flags, and apply the triplet flags again. The verification step of qt-base is missing. This still leads to double flags and breaks cross builds.

Fixing the approach here likely leads to ripping of the Qt build system. I don't think that we have a real world problem that rectifies the works.

But anyway, I have no interest to spend more work here, because with Mixxx, I have cross build of QT5 working as an overlay.

@JavierMatosD JavierMatosD marked this pull request as ready for review June 5, 2023 18:38
@@ -123,4 +123,11 @@ function(qt_build_submodule SOURCE_PATH)
endif()
endif()

# Remove duplicate flags from qmodule.pri issue -> https://github.com/microsoft/vcpkg/issues/28835
if(EXISTS "${CURRENT_INSTALLED_DIR}/tools/qt5/mkspecs/qmodule.pri")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this exists check.. exist? :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's safe to assume that qmodule.pri will exist. :)

Adela0814
Adela0814 previously approved these changes Jun 6, 2023
@Adela0814 Adela0814 added the info:reviewed Pull Request changes follow basic guidelines label Jun 6, 2023
@Adela0814 Adela0814 changed the title Remove duplicate flags qt [qt5-base] Remove duplicate flags qt Jun 6, 2023
@Adela0814 Adela0814 added the info:internal This PR or Issue was filed by the vcpkg team. label Jun 6, 2023
# Conflicts:
#	ports/qt5-base/vcpkg.json
#	versions/baseline.json
#	versions/q-/qt5-base.json
@JavierMatosD JavierMatosD merged commit dcd0450 into microsoft:master Jun 13, 2023
15 checks passed
@JavierMatosD JavierMatosD deleted the remove_duplicate_flags_qt branch October 31, 2023 23:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:community-triplet A PR or issue related to community triplets not officially validated by the vcpkg team. category:port-bug The issue is with a library, which is something the port should already support info:internal This PR or Issue was filed by the vcpkg team. info:reviewed Pull Request changes follow basic guidelines
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants