Skip to content

Commit

Permalink
Make QLever compile with g++-13 (ad-freiburg#991)
Browse files Browse the repository at this point in the history
  • Loading branch information
joka921 authored May 24, 2023
1 parent c9abf99 commit 3911eb6
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 19 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/native-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
fail-fast: false
matrix:
compiler: [gcc, clang]
compiler-version: [11, 12, 16]
compiler-version: [11, 12, 13, 16]
warnings: [ "-Wall -Wextra -Werror " ]
build-type: [Release]
exclude:
Expand All @@ -27,6 +27,8 @@ jobs:
compiler-version: 11
- compiler: clang
compiler-version: 12
- compiler: clang
compiler-version: 13
include:
- compiler: clang
asan-flags: "-fsanitize=address -fno-omit-frame-pointer"
Expand Down Expand Up @@ -55,6 +57,11 @@ jobs:
- name: Install gcc 12
run : sudo add-apt-repository ppa:ubuntu-toolchain-r/test && sudo apt update && sudo apt install -y gcc-12 g++-12
if : matrix.compiler == 'gcc' && matrix.compiler-version == 12

- name: Install gcc 13
run : sudo add-apt-repository ppa:ubuntu-toolchain-r/test && sudo apt update && sudo apt install -y gcc-13 g++-13
if : matrix.compiler == 'gcc' && matrix.compiler-version == 13

- name: Install clang 16
# The sed command fixes a bug in `llvm.sh` in combination with the latest version of
# `apt-key`. Without it the GPG key for the llvm repository is downloaded but deleted
Expand Down
12 changes: 8 additions & 4 deletions src/engine/Operation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,10 +313,14 @@ void Operation::createRuntimeInfoFromEstimates() {
return;
}
// TODO<joka921> If the above stuff works, this can be removed.
std::optional<RuntimeInformation::Status> statusFromPrecomputedResult =
getPrecomputedResultFromQueryPlanning().has_value()
? std::optional{_runtimeInfo.status_}
: std::nullopt;
auto statusFromPrecomputedResult =
[this]() -> std::optional<RuntimeInformation::Status> {
if (getPrecomputedResultFromQueryPlanning().has_value()) {
return _runtimeInfo.status_;
} else {
return std::nullopt;
}
}();
_runtimeInfo.setColumnNames(getInternallyVisibleVariableColumns());
const auto numCols = getResultWidth();
_runtimeInfo.numCols_ = numCols;
Expand Down
29 changes: 16 additions & 13 deletions src/index/FTSAlgorithms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
#include <set>
#include <utility>

#include "../util/HashMap.h"
#include "../util/HashSet.h"
#include "util/HashMap.h"
#include "util/HashSet.h"
#include "util/SuppressWarnings.h"

using std::pair;

Expand Down Expand Up @@ -395,17 +396,19 @@ void FTSAlgorithms::aggScoresAndTakeTopKContexts(vector<Row>& nonAggRes,
if (nonAggRes.empty()) return;

size_t width = nonAggRes[0].size();
std::sort(nonAggRes.begin(), nonAggRes.end(),
[&width](const Row& l, const Row& r) {
if (l[0] == r[0]) {
for (size_t i = 3; i < width; ++i) {
if (l[i] == r[i]) continue;
return l[i] < r[i];
}
return l[1] < r[1];
}
return l[0] < r[0];
});
std::ranges::sort(nonAggRes, [width](const Row& l, const Row& r) {
if (l[0] != r[0]) {
return l[0] < r[0];
}
for (size_t i = 3; i < width; ++i) {
DISABLE_WARNINGS_GCC_13
if (l[i] != r[i]) {
ENABLE_WARNINGS_GCC_13
return l[i] < r[i];
}
}
return l[1] < r[1];
});

res.push_back(nonAggRes[0]);
size_t contextsInResult = 1;
Expand Down
1 change: 1 addition & 0 deletions src/util/Iterators.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#ifndef QLEVER_ITERATORS_H
#define QLEVER_ITERATORS_H

#include <cstdint>
#include <iterator>
#include <type_traits>

Expand Down
30 changes: 30 additions & 0 deletions src/util/SuppressWarnings.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright 2023, University of Freiburg,
// Chair of Algorithms and Data Structures.
// Author: Johannes Kalmbach(joka921) <[email protected]>

#pragma once

#include <functional>
#include <type_traits>

// This file contains helper functions and macros to suppress false-positive
// warnings on certain compilers. These should be used rarely and only if it is
// really sure that the suppressed warnings are false positives and that there
// is no feasible way to avoid them.

// Macros to disable and reenable certain warnings on GCC13. Currently some
// (valid) uses of `std::sort` trigger a false positive `-Warray-bounds`
// warning. It is important that there is a corresponding `ENABLE_...` macro
// issued for every `DISABLE_...` macro.
#if __GNUC__ == 13
#define DISABLE_WARNINGS_GCC_13 \
_Pragma("GCC diagnostic push") \
_Pragma("GCC diagnostic ignored \"-Warray-bounds\"")

#define ENABLE_WARNINGS_GCC_13 _Pragma("GCC diagnostic pop")
#endif

#ifndef DISABLE_WARNINGS_GCC_13
#define DISABLE_WARNINGS_GCC_13
#define ENABLE_WARNINGS_GCC_13
#endif
2 changes: 1 addition & 1 deletion third_party/stxxl
Submodule stxxl updated 1 files
+1 −1 extlib/foxxll
3 changes: 3 additions & 0 deletions toolchains/gcc13.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Toolchain that uses G++ 13
set(CMAKE_C_COMPILER gcc-13)
set(CMAKE_CXX_COMPILER g++-13)

0 comments on commit 3911eb6

Please sign in to comment.