Skip to content

Commit

Permalink
Fixes for GCC 13 and LLVM 17 (#1749)
Browse files Browse the repository at this point in the history
  • Loading branch information
ntadej authored Oct 14, 2023
1 parent 89b9c39 commit a3e3290
Show file tree
Hide file tree
Showing 9 changed files with 120 additions and 44 deletions.
134 changes: 100 additions & 34 deletions .github/workflows/qt-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
branches:
- main
tags:
- 'qt-**'
- "qt-**"
paths:
- CMakeLists.txt
- ".github/actions/qt5-build/**"
Expand All @@ -28,7 +28,7 @@ on:

pull_request:
branches:
- '*'
- "*"
paths:
- CMakeLists.txt
- ".github/actions/qt5-build/**"
Expand Down Expand Up @@ -63,25 +63,43 @@ jobs:
build_type: RelWithDebInfo
qt_version: 5.15.2
qt_target: desktop
compiler: ""
- name: Linux
os: ubuntu-22.04
build_type: RelWithDebInfo
qt_version: 6.5.0
qt_version: 6.5.3
qt_target: desktop
compiler: ""
- name: Linux_GCC13
os: ubuntu-22.04
build_type: RelWithDebInfo
qt_version: 6.5.3
qt_target: desktop
compiler: "gcc-13"
- name: macOS
os: macos-12
build_type: RelWithDebInfo
qt_version: 5.15.2
qt_target: desktop
deployment_target: 10.13
deployment_arch: "x86_64"
compiler: ""
- name: macOS
os: macos-12
build_type: RelWithDebInfo
qt_version: 6.5.0
qt_version: 6.5.3
qt_target: desktop
deployment_target: 11.0
deployment_arch: "x86_64;arm64"
compiler: ""
- name: macOS_LLVM17
os: macos-13
build_type: RelWithDebInfo
qt_version: 6.5.3
qt_target: desktop
deployment_target: 11.0
deployment_arch: "x86_64"
compiler: "llvm@17"
- name: win64_msvc2019
os: windows-2022
build_type: "RelWithDebInfo;Debug"
Expand All @@ -90,16 +108,16 @@ jobs:
qt_version: 5.15.2
qt_target: desktop
qt_arch: win64_msvc2019_64
qt_tools: ''
qt_tools: ""
- name: win64_msvc2019
os: windows-2022
build_type: "RelWithDebInfo;Debug"
compiler_type: x64
compiler_version: 14.29
qt_version: 6.5.0
qt_version: 6.5.3
qt_target: desktop
qt_arch: win64_msvc2019_64
qt_tools: ''
qt_tools: ""
- name: win64_mingw
os: windows-2022
build_type: RelWithDebInfo
Expand All @@ -114,7 +132,7 @@ jobs:
build_type: RelWithDebInfo
compiler_type: mingw1120_64
compiler_version: 11.2.0
qt_version: 6.5.0
qt_version: 6.5.3
qt_target: desktop
qt_arch: win64_mingw
qt_tools: tools_mingw90
Expand Down Expand Up @@ -155,6 +173,38 @@ jobs:
- name: Setup ninja
uses: seanmiddleditch/gha-setup-ninja@v4

- name: Install compiler
id: install_compiler
if: runner.os == 'Linux' && matrix.compiler != ''
uses: rlalik/setup-cpp-compiler@master
with:
compiler: ${{ matrix.compiler }}

- name: Setup compiler (Linux)
if: runner.os == 'Linux' && matrix.compiler != ''
env:
CC: ${{ steps.install_compiler.outputs.cc }}
CXX: ${{ steps.install_compiler.outputs.cxx }}
run: |
{
echo "CC=$CC"
echo "CXX=$CXX"
} >> "$GITHUB_ENV"
- name: Setup compiler (macOS)
if: runner.os == 'macOS' && matrix.compiler != ''
env:
MLN_COMPILER: ${{ matrix.compiler }}
run: |
brew install "$MLN_COMPILER"
echo "/usr/local/opt/${MLN_COMPILER}/bin" >> "$GITHUB_PATH"
{
echo "CC=/usr/local/opt/${MLN_COMPILER}/bin/clang"
echo "CXX=/usr/local/opt/${MLN_COMPILER}/bin/clang++"
echo "LDFLAGS=\"-L/usr/local/opt/${MLN_COMPILER}/lib\""
echo "CPPFLAGS=\"-I/usr/local/opt/${MLN_COMPILER}/include\""
} >> "$GITHUB_ENV"
- name: Setup Xcode
if: runner.os == 'macOS'
uses: maxim-lobanov/setup-xcode@v1
Expand Down Expand Up @@ -204,9 +254,25 @@ jobs:
uses: ./source/.github/actions/qt5-build

- name: Build maplibre-native (Linux, Qt6)
if: runner.os == 'Linux' && matrix.qt_version != '5.15.2'
if: runner.os == 'Linux' && matrix.qt_version != '5.15.2' && matrix.compiler == ''
uses: ./source/.github/actions/qt6-build

- name: Build maplibre-native (Linux, Qt6, custom compiler)
if: runner.os == 'Linux' && matrix.qt_version != '5.15.2' && matrix.compiler != ''
run: |
mkdir build && cd build
qt-cmake ../source/ \
-G Ninja \
-DCMAKE_BUILD_TYPE="${BUILD_TYPE}" \
-DCMAKE_C_COMPILER_LAUNCHER="ccache" \
-DCMAKE_CXX_COMPILER_LAUNCHER="ccache" \
-DCMAKE_INSTALL_PREFIX="../install" \
-DMLN_WITH_QT=ON \
-DMLN_QT_DEPLOYMENT=ON \
-DMLN_QT_WITH_INTERNAL_ICU=ON
ninja
ninja install
- name: Build maplibre-native (Windows)
if: runner.os == 'Windows'
shell: bash
Expand Down Expand Up @@ -238,7 +304,7 @@ jobs:
QT_VERSION: ${{ matrix.qt_version }}
run: |
pushd install
tar cjvf ../maplibre-native_"${QT_ARCH}"_Qt"${QT_VERSION}".tar.bz2 ./*
tar cjvf "../maplibre-native_${QT_ARCH}_Qt${QT_VERSION}.tar.bz2" ./*
popd
- name: Upload artifacts
Expand All @@ -254,11 +320,11 @@ jobs:
include:
- name: Linux
os: ubuntu-22.04
qt_version: 6.5.0
qt_version: 6.5.3
qt_target: desktop
- name: macOS
os: macos-12
qt_version: 6.5.0
qt_version: 6.5.3
qt_target: desktop
runs-on: ${{ matrix.os }}
env:
Expand Down Expand Up @@ -294,9 +360,9 @@ jobs:
- name: Build test app
run: |
mkdir install && cd install
tar xf ../maplibre-native_"${QT_ARCH}"_Qt"${QT_VERSION}".tar.bz2
tar xf "../maplibre-native_${QT_ARCH}_Qt${QT_VERSION}.tar.bz2"
cd ..
export CMAKE_PREFIX_PATH="$PWD"/install
export CMAKE_PREFIX_PATH="$PWD/install"
mkdir build && cd build
cmake ../source/platform/qt/app/
make
Expand All @@ -310,27 +376,27 @@ jobs:
max-parallel: 1
matrix:
name: [Linux, macOS, win64_msvc2019, win64_mingw]
qt_version: [5.15.2, 6.5.0]
qt_version: [5.15.2, 6.5.3]
permissions:
contents: write

steps:
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: maplibre-native_${{ matrix.name }}_Qt${{ matrix.qt_version }}

- name: Name tarball
env:
TAG_NAME: ${{ github.ref_name }}
TAG_PLATFORM: ${{ matrix.name }}
QT_VERSION: ${{ matrix.qt_version }}
run: |
mv maplibre-native_"${TAG_PLATFORM}"_Qt"${QT_VERSION}".tar.bz2 QMapLibreGL_"${TAG_NAME//qt-/}"_Qt"${QT_VERSION}"_"${TAG_PLATFORM}".tar.bz2
- name: Release
uses: ncipollo/release-action@v1
with:
artifacts: QMapLibreGL_*.tar.bz2
allowUpdates: true
draft: true
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: maplibre-native_${{ matrix.name }}_Qt${{ matrix.qt_version }}

- name: Name tarball
env:
TAG_NAME: ${{ github.ref_name }}
TAG_PLATFORM: ${{ matrix.name }}
QT_VERSION: ${{ matrix.qt_version }}
run: |
mv "maplibre-native_${TAG_PLATFORM}_Qt${QT_VERSION}.tar.bz2" "QMapLibreGL_${TAG_NAME//qt-/}_Qt${QT_VERSION}_${TAG_PLATFORM}.tar.bz2"
- name: Release
uses: ncipollo/release-action@v1
with:
artifacts: QMapLibreGL_*.tar.bz2
allowUpdates: true
draft: true
1 change: 1 addition & 0 deletions include/mbgl/gfx/shader_group.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <memory>
#include <mutex>
#include <shared_mutex>
#include <string>
#include <unordered_map>
#include <unordered_set>

Expand Down
1 change: 1 addition & 0 deletions include/mbgl/gfx/shader_registry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <memory>
#include <mutex>
#include <shared_mutex>
#include <string>
#include <unordered_map>

namespace mbgl {
Expand Down
4 changes: 2 additions & 2 deletions include/mbgl/style/transition_options.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ class TransitionOptions {
TransitionOptions(std::optional<Duration> duration_ = std::nullopt,
std::optional<Duration> delay_ = std::nullopt,
bool enablePlacementTransitions_ = true)
: duration(std::move(duration_)),
delay(std::move(delay_)),
: duration(duration_ ? std::move(duration_) : std::nullopt),
delay(delay_ ? std::move(delay_) : std::nullopt),
enablePlacementTransitions(enablePlacementTransitions_) {}

TransitionOptions reverseMerge(const TransitionOptions& defaults) const {
Expand Down
1 change: 1 addition & 0 deletions include/mbgl/util/compression.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include <cstdint>
#include <string>

namespace mbgl {
Expand Down
6 changes: 3 additions & 3 deletions src/mbgl/renderer/sources/render_tile_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,12 +314,12 @@ RenderTiles RenderTileSource::getRenderTiles() const {

RenderTiles RenderTileSource::getRenderTilesSortedByYPosition() const {
if (!renderTilesSortedByY) {
const auto comp = [bearing = this->bearing](const RenderTile& a, const RenderTile& b) {
const auto comp = [sourceBearing = this->bearing](const RenderTile& a, const RenderTile& b) {
Point<float> pa(static_cast<float>(a.id.canonical.x), static_cast<float>(a.id.canonical.y));
Point<float> pb(static_cast<float>(b.id.canonical.x), static_cast<float>(b.id.canonical.y));

auto par = util::rotate(pa, bearing);
auto pbr = util::rotate(pb, bearing);
auto par = util::rotate(pa, sourceBearing);
auto pbr = util::rotate(pb, sourceBearing);

return std::tie(b.id.canonical.z, par.y, par.x) < std::tie(a.id.canonical.z, pbr.y, pbr.x);
};
Expand Down
8 changes: 4 additions & 4 deletions src/mbgl/style/conversion/transition_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ std::optional<TransitionOptions> Converter<TransitionOptions>::operator()(const
return std::nullopt;
}

std::optional<TransitionOptions> result = TransitionOptions{};
auto result = TransitionOptions{};

auto duration = objectMember(value, "duration");
if (duration) {
Expand All @@ -21,7 +21,7 @@ std::optional<TransitionOptions> Converter<TransitionOptions>::operator()(const
error.message = "duration must be a number";
return std::nullopt;
}
result->duration = {std::chrono::milliseconds(int64_t(*number))};
result.duration = {std::chrono::milliseconds(int64_t(*number))};
}

auto delay = objectMember(value, "delay");
Expand All @@ -31,10 +31,10 @@ std::optional<TransitionOptions> Converter<TransitionOptions>::operator()(const
error.message = "delay must be a number";
return std::nullopt;
}
result->delay = {std::chrono::milliseconds(int64_t(*number))};
result.delay = {std::chrono::milliseconds(int64_t(*number))};
}

return result;
return std::make_optional(std::move(result));
}

} // namespace conversion
Expand Down
5 changes: 4 additions & 1 deletion src/mbgl/style/sources/geojson_source_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ class GeoJSONVTData final : public GeoJSONData {
void getTile(const CanonicalTileID& id, const std::function<void(TileFeatures)>& fn) final {
assert(fn);
scheduler->scheduleAndReplyValue(
[id, impl = this->impl]() -> TileFeatures { return impl->getTile(id.z, id.x, id.y).features; }, fn);
[id, geoJSONVT_impl = this->impl]() -> TileFeatures {
return geoJSONVT_impl->getTile(id.z, id.x, id.y).features;
},
fn);
}

Features getChildren(const std::uint32_t) final { return {}; }
Expand Down
4 changes: 4 additions & 0 deletions test/util/thread.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,10 @@ TEST(Thread, ThreadPoolMessaging) {
}

TEST(Thread, ReferenceCanOutliveThread) {
#if defined(__GNUC__) && __GNUC__ >= 12
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wuse-after-free" // See AspiringActor<>::object()
#endif
auto thread = std::make_unique<Thread<TestWorker>>("Test");
auto worker = thread->actor();

Expand All @@ -196,7 +198,9 @@ TEST(Thread, ReferenceCanOutliveThread) {

using namespace std::literals;
std::this_thread::sleep_for(10s);
#if defined(__GNUC__) && __GNUC__ >= 12
#pragma GCC diagnostic pop
#endif
}

TEST(Thread, DeletePausedThread) {
Expand Down

0 comments on commit a3e3290

Please sign in to comment.