Enable C++17 (#4623)
This commit is contained in:
committed by
Nikolay Krasko
parent
ee9c2f0e33
commit
a362742a37
+1
-1
@@ -10,6 +10,6 @@ import org.jetbrains.kotlin.konan.target.*
|
|||||||
import org.jetbrains.kotlin.konan.file.*
|
import org.jetbrains.kotlin.konan.file.*
|
||||||
|
|
||||||
fun produceCAdapterBitcode(clang: ClangArgs, cppFileName: String, bitcodeFileName: String) {
|
fun produceCAdapterBitcode(clang: ClangArgs, cppFileName: String, bitcodeFileName: String) {
|
||||||
val clangCommand = clang.clangCXX("-std=c++14", cppFileName, "-emit-llvm", "-c", "-o", bitcodeFileName)
|
val clangCommand = clang.clangCXX("-std=c++17", cppFileName, "-emit-llvm", "-c", "-o", bitcodeFileName)
|
||||||
Command(clangCommand).execute()
|
Command(clangCommand).execute()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ linker = clang++
|
|||||||
linkerOpts = -fvisibility-inlines-hidden \
|
linkerOpts = -fvisibility-inlines-hidden \
|
||||||
-Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers \
|
-Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers \
|
||||||
-pedantic -Wno-long-long -Wcovered-switch-default -Wnon-virtual-dtor -Wdelete-non-virtual-dtor \
|
-pedantic -Wno-long-long -Wcovered-switch-default -Wnon-virtual-dtor -Wdelete-non-virtual-dtor \
|
||||||
-std=c++14 \
|
-std=c++17 \
|
||||||
-DNDEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS \
|
-DNDEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS \
|
||||||
-ldebugInfo -lcoverageMapping
|
-ldebugInfo -lcoverageMapping
|
||||||
|
|
||||||
|
|||||||
@@ -3723,7 +3723,7 @@ createInterop("concurrentTerminate") {
|
|||||||
it.headers "$projectDir/interop/concurrentTerminate/async.h"
|
it.headers "$projectDir/interop/concurrentTerminate/async.h"
|
||||||
// TODO: Using `-Xcompile-source` does not imply dependency on that source, so the task will no re-run when the source is updated.
|
// TODO: Using `-Xcompile-source` does not imply dependency on that source, so the task will no re-run when the source is updated.
|
||||||
it.extraOpts "-Xcompile-source", "$projectDir/interop/concurrentTerminate/async.cpp"
|
it.extraOpts "-Xcompile-source", "$projectDir/interop/concurrentTerminate/async.cpp"
|
||||||
it.extraOpts "-Xsource-compiler-option", "-std=c++11"
|
it.extraOpts "-Xsource-compiler-option", "-std=c++17"
|
||||||
}
|
}
|
||||||
|
|
||||||
createInterop("incomplete_types") {
|
createInterop("incomplete_types") {
|
||||||
|
|||||||
+1
-1
@@ -68,7 +68,7 @@ open class CompileToBitcode @Inject constructor(
|
|||||||
// Used flags provided by original build of allocator C code.
|
// Used flags provided by original build of allocator C code.
|
||||||
listOf("-std=gnu11", "-O3", "-Wall", "-Wextra", "-Werror")
|
listOf("-std=gnu11", "-O3", "-Wall", "-Wextra", "-Werror")
|
||||||
Language.CPP ->
|
Language.CPP ->
|
||||||
listOfNotNull("-std=c++14", "-Werror", "-O2",
|
listOfNotNull("-std=c++17", "-Werror", "-O2",
|
||||||
"-Wall", "-Wextra",
|
"-Wall", "-Wextra",
|
||||||
"-Wno-unused-parameter", // False positives with polymorphic functions.
|
"-Wno-unused-parameter", // False positives with polymorphic functions.
|
||||||
"-fPIC".takeIf { !HostManager().targetByName(target).isMINGW })
|
"-fPIC".takeIf { !HostManager().targetByName(target).isMINGW })
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ model {
|
|||||||
binaries.withType(StaticLibraryBinarySpec) { binary ->
|
binaries.withType(StaticLibraryBinarySpec) { binary ->
|
||||||
if (!project.parent.convention.plugins.platformInfo.isWindows())
|
if (!project.parent.convention.plugins.platformInfo.isWindows())
|
||||||
cppCompiler.args "-fPIC"
|
cppCompiler.args "-fPIC"
|
||||||
cppCompiler.args "--std=c++11", "-g", "-I${llvmDir}/include"
|
cppCompiler.args "--std=c++17", "-g", "-I${llvmDir}/include"
|
||||||
if (isEnabled) {
|
if (isEnabled) {
|
||||||
cppCompiler.args '-DLIBCLANGEXT_ENABLE=1'
|
cppCompiler.args '-DLIBCLANGEXT_ENABLE=1'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ model {
|
|||||||
binaries.withType(StaticLibraryBinarySpec) { binary ->
|
binaries.withType(StaticLibraryBinarySpec) { binary ->
|
||||||
if (!project.parent.convention.plugins.platformInfo.isWindows())
|
if (!project.parent.convention.plugins.platformInfo.isWindows())
|
||||||
cppCompiler.args "-fPIC"
|
cppCompiler.args "-fPIC"
|
||||||
cppCompiler.args "--std=c++14", "-I${llvmDir}/include", "-I${projectDir}/src/main/include"
|
cppCompiler.args "--std=c++17", "-I${llvmDir}/include", "-I${projectDir}/src/main/include"
|
||||||
if (isMac()) {
|
if (isMac()) {
|
||||||
cppCompiler.args "-DKONAN_MACOS=1"
|
cppCompiler.args "-DKONAN_MACOS=1"
|
||||||
} else if (isWindows()) {
|
} else if (isWindows()) {
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ model {
|
|||||||
binaries.withType(StaticLibraryBinarySpec) { binary ->
|
binaries.withType(StaticLibraryBinarySpec) { binary ->
|
||||||
if (!project.parent.convention.plugins.platformInfo.isWindows())
|
if (!project.parent.convention.plugins.platformInfo.isWindows())
|
||||||
cppCompiler.args "-fPIC"
|
cppCompiler.args "-fPIC"
|
||||||
cppCompiler.args "--std=c++14", "-I${llvmDir}/include", "-I${projectDir}/src/main/include"
|
cppCompiler.args "--std=c++17", "-I${llvmDir}/include", "-I${projectDir}/src/main/include"
|
||||||
linker.args "-L${llvmDir}/lib", "-lLLVMCore", "-lLLVMSupport"
|
linker.args "-L${llvmDir}/lib", "-lLLVMCore", "-lLLVMSupport"
|
||||||
}
|
}
|
||||||
binaries.withType(SharedLibraryBinarySpec) { binary ->
|
binaries.withType(SharedLibraryBinarySpec) { binary ->
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
#include <llvm-c/DebugInfo.h>
|
#include <llvm-c/DebugInfo.h>
|
||||||
#include "DebugInfoC.h"
|
#include "DebugInfoC.h"
|
||||||
/**
|
/**
|
||||||
* c++ --std=c++14 llvmDebugInfoC/src/DebugInfoC.cpp -IllvmDebugInfoC/include/ -Idependencies/all/clang+llvm-3.9.0-darwin-macos/include -Ldependencies/all/clang+llvm-3.9.0-darwin-macos/lib -lLLVMCore -lLLVMSupport -lncurses -shared -o libLLVMDebugInfoC.dylib
|
* c++ --std=c++17 llvmDebugInfoC/src/DebugInfoC.cpp -IllvmDebugInfoC/include/ -Idependencies/all/clang+llvm-3.9.0-darwin-macos/include -Ldependencies/all/clang+llvm-3.9.0-darwin-macos/lib -lLLVMCore -lLLVMSupport -lncurses -shared -o libLLVMDebugInfoC.dylib
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
|||||||
@@ -6,39 +6,11 @@
|
|||||||
#ifndef RUNTIME_CPP_SUPPORT_H
|
#ifndef RUNTIME_CPP_SUPPORT_H
|
||||||
#define RUNTIME_CPP_SUPPORT_H
|
#define RUNTIME_CPP_SUPPORT_H
|
||||||
|
|
||||||
#include <type_traits>
|
|
||||||
|
|
||||||
// A collection of backported utilities from future C++ versions.
|
// A collection of backported utilities from future C++ versions.
|
||||||
|
|
||||||
namespace kotlin {
|
namespace kotlin {
|
||||||
namespace std_support {
|
namespace std_support {
|
||||||
|
|
||||||
////////////////////////// C++14 //////////////////////////
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
using make_unsigned_t = typename std::make_unsigned<T>::type;
|
|
||||||
|
|
||||||
////////////////////////// C++17 //////////////////////////
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
constexpr bool is_trivially_destructible_v = std::is_trivially_destructible<T>::value;
|
|
||||||
template <typename T>
|
|
||||||
constexpr bool is_nothrow_default_constructible_v = std::is_nothrow_default_constructible<T>::value;
|
|
||||||
template <typename T>
|
|
||||||
constexpr bool is_nothrow_destructible_v = std::is_nothrow_destructible<T>::value;
|
|
||||||
template <typename T>
|
|
||||||
constexpr bool is_copy_constructible_v = std::is_copy_constructible<T>::value;
|
|
||||||
template <typename T>
|
|
||||||
constexpr bool is_copy_assignable_v = std::is_copy_assignable<T>::value;
|
|
||||||
template <typename T>
|
|
||||||
constexpr bool is_move_constructible_v = std::is_move_constructible<T>::value;
|
|
||||||
template <typename T>
|
|
||||||
constexpr bool is_move_assignable_v = std::is_move_assignable<T>::value;
|
|
||||||
template <typename T>
|
|
||||||
constexpr bool is_nothrow_move_constructible_v = std::is_nothrow_move_constructible<T>::value;
|
|
||||||
template <typename T>
|
|
||||||
constexpr bool is_nothrow_move_assignable_v = std::is_nothrow_move_assignable<T>::value;
|
|
||||||
|
|
||||||
} // namespace std_support
|
} // namespace std_support
|
||||||
} // namespace kotlin
|
} // namespace kotlin
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
#include "CppSupport.hpp"
|
|
||||||
#include "Memory.h"
|
#include "Memory.h"
|
||||||
|
|
||||||
// TODO: Generalize for uses outside this file.
|
// TODO: Generalize for uses outside this file.
|
||||||
@@ -38,8 +37,7 @@ class KRefSharedHolder {
|
|||||||
ForeignRefContext context_;
|
ForeignRefContext context_;
|
||||||
};
|
};
|
||||||
|
|
||||||
static_assert(
|
static_assert(std::is_trivially_destructible_v<KRefSharedHolder>, "KRefSharedHolder destructor is not guaranteed to be called.");
|
||||||
kotlin::std_support::is_trivially_destructible_v<KRefSharedHolder>, "KRefSharedHolder destructor is not guaranteed to be called.");
|
|
||||||
|
|
||||||
class BackRefFromAssociatedObject {
|
class BackRefFromAssociatedObject {
|
||||||
public:
|
public:
|
||||||
@@ -68,7 +66,7 @@ class BackRefFromAssociatedObject {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static_assert(
|
static_assert(
|
||||||
kotlin::std_support::is_trivially_destructible_v<BackRefFromAssociatedObject>,
|
std::is_trivially_destructible_v<BackRefFromAssociatedObject>,
|
||||||
"BackRefFromAssociatedObject destructor is not guaranteed to be called.");
|
"BackRefFromAssociatedObject destructor is not guaranteed to be called.");
|
||||||
|
|
||||||
#endif // RUNTIME_MEMORYSHAREDREFS_HPP
|
#endif // RUNTIME_MEMORYSHAREDREFS_HPP
|
||||||
|
|||||||
@@ -21,7 +21,6 @@
|
|||||||
#include <limits>
|
#include <limits>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
#include "CppSupport.hpp"
|
|
||||||
#include "KAssert.h"
|
#include "KAssert.h"
|
||||||
#include "Exceptions.h"
|
#include "Exceptions.h"
|
||||||
#include "Memory.h"
|
#include "Memory.h"
|
||||||
@@ -51,7 +50,7 @@ OBJ_GETTER0(Kotlin_native_internal_undefined) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void* Kotlin_interop_malloc(KLong size, KInt align) {
|
void* Kotlin_interop_malloc(KLong size, KInt align) {
|
||||||
if (size < 0 || static_cast<kotlin::std_support::make_unsigned_t<decltype(size)>>(size) > std::numeric_limits<size_t>::max()) {
|
if (size < 0 || static_cast<std::make_unsigned_t<decltype(size)>>(size) > std::numeric_limits<size_t>::max()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
RuntimeAssert(align > 0, "Unsupported alignment");
|
RuntimeAssert(align > 0, "Unsupported alignment");
|
||||||
|
|||||||
@@ -6,8 +6,6 @@
|
|||||||
#ifndef RUNTIME_UTILS_H
|
#ifndef RUNTIME_UTILS_H
|
||||||
#define RUNTIME_UTILS_H
|
#define RUNTIME_UTILS_H
|
||||||
|
|
||||||
#include "CppSupport.hpp"
|
|
||||||
|
|
||||||
namespace kotlin {
|
namespace kotlin {
|
||||||
|
|
||||||
// A helper for implementing classes with disabled copy constructor and copy assignment.
|
// A helper for implementing classes with disabled copy constructor and copy assignment.
|
||||||
|
|||||||
@@ -5,9 +5,9 @@
|
|||||||
|
|
||||||
#include "Utils.hpp"
|
#include "Utils.hpp"
|
||||||
|
|
||||||
#include "gtest/gtest.h"
|
#include <type_traits>
|
||||||
|
|
||||||
#include "CppSupport.hpp"
|
#include "gtest/gtest.h"
|
||||||
|
|
||||||
using namespace kotlin;
|
using namespace kotlin;
|
||||||
|
|
||||||
@@ -30,21 +30,21 @@ public:
|
|||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
TEST(UtilsTest, MoveOnlyImpl) {
|
TEST(UtilsTest, MoveOnlyImpl) {
|
||||||
static_assert(std_support::is_nothrow_default_constructible_v<MoveOnlyImpl>, "Must be nothrow default constructible");
|
static_assert(std::is_nothrow_default_constructible_v<MoveOnlyImpl>, "Must be nothrow default constructible");
|
||||||
static_assert(std_support::is_nothrow_destructible_v<MoveOnlyImpl>, "Must be nothrow destructible");
|
static_assert(std::is_nothrow_destructible_v<MoveOnlyImpl>, "Must be nothrow destructible");
|
||||||
static_assert(!std_support::is_copy_constructible_v<MoveOnlyImpl>, "Must not be copy constructible");
|
static_assert(!std::is_copy_constructible_v<MoveOnlyImpl>, "Must not be copy constructible");
|
||||||
static_assert(!std_support::is_copy_assignable_v<MoveOnlyImpl>, "Must not be copy assignable");
|
static_assert(!std::is_copy_assignable_v<MoveOnlyImpl>, "Must not be copy assignable");
|
||||||
static_assert(std_support::is_nothrow_move_constructible_v<MoveOnlyImpl>, "Must be nothrow move constructible");
|
static_assert(std::is_nothrow_move_constructible_v<MoveOnlyImpl>, "Must be nothrow move constructible");
|
||||||
static_assert(std_support::is_nothrow_move_assignable_v<MoveOnlyImpl>, "Must be nothrow move assignable");
|
static_assert(std::is_nothrow_move_assignable_v<MoveOnlyImpl>, "Must be nothrow move assignable");
|
||||||
static_assert(sizeof(MoveOnlyImpl) == sizeof(A), "Must not increase size");
|
static_assert(sizeof(MoveOnlyImpl) == sizeof(A), "Must not increase size");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(UtilsTest, PinnedImpl) {
|
TEST(UtilsTest, PinnedImpl) {
|
||||||
static_assert(std_support::is_nothrow_default_constructible_v<PinnedImpl>, "Must be nothrow default constructible");
|
static_assert(std::is_nothrow_default_constructible_v<PinnedImpl>, "Must be nothrow default constructible");
|
||||||
static_assert(std_support::is_nothrow_destructible_v<PinnedImpl>, "Must be nothrow destructible");
|
static_assert(std::is_nothrow_destructible_v<PinnedImpl>, "Must be nothrow destructible");
|
||||||
static_assert(!std_support::is_copy_constructible_v<PinnedImpl>, "Must not be copy constructible");
|
static_assert(!std::is_copy_constructible_v<PinnedImpl>, "Must not be copy constructible");
|
||||||
static_assert(!std_support::is_copy_assignable_v<PinnedImpl>, "Must not be copy assignable");
|
static_assert(!std::is_copy_assignable_v<PinnedImpl>, "Must not be copy assignable");
|
||||||
static_assert(!std_support::is_move_constructible_v<PinnedImpl>, "Must not be move constructible");
|
static_assert(!std::is_move_constructible_v<PinnedImpl>, "Must not be move constructible");
|
||||||
static_assert(!std_support::is_move_assignable_v<PinnedImpl>, "Must not be move assignable");
|
static_assert(!std::is_move_assignable_v<PinnedImpl>, "Must not be move assignable");
|
||||||
static_assert(sizeof(PinnedImpl) == sizeof(A), "Must not increase size");
|
static_assert(sizeof(PinnedImpl) == sizeof(A), "Must not increase size");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,10 +9,10 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
#include "Alignment.hpp"
|
#include "Alignment.hpp"
|
||||||
#include "Alloc.h"
|
#include "Alloc.h"
|
||||||
#include "CppSupport.hpp"
|
|
||||||
#include "Memory.h"
|
#include "Memory.h"
|
||||||
#include "Mutex.hpp"
|
#include "Mutex.hpp"
|
||||||
#include "Types.h"
|
#include "Types.h"
|
||||||
@@ -106,7 +106,7 @@ public:
|
|||||||
template <typename T, typename... Args>
|
template <typename T, typename... Args>
|
||||||
Node& Insert(Args&&... args) noexcept {
|
Node& Insert(Args&&... args) noexcept {
|
||||||
static_assert(alignof(T) <= DataAlignment, "Cannot insert type with alignment bigger than DataAlignment");
|
static_assert(alignof(T) <= DataAlignment, "Cannot insert type with alignment bigger than DataAlignment");
|
||||||
static_assert(std_support::is_trivially_destructible_v<T>, "Type must be trivially destructible");
|
static_assert(std::is_trivially_destructible_v<T>, "Type must be trivially destructible");
|
||||||
auto& node = Insert(sizeof(T));
|
auto& node = Insert(sizeof(T));
|
||||||
new (node.Data()) T(std::forward<Args>(args)...);
|
new (node.Data()) T(std::forward<Args>(args)...);
|
||||||
return node;
|
return node;
|
||||||
|
|||||||
@@ -7,11 +7,11 @@
|
|||||||
|
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
#include "gmock/gmock.h"
|
#include "gmock/gmock.h"
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
|
|
||||||
#include "CppSupport.hpp"
|
|
||||||
#include "TestSupport.hpp"
|
#include "TestSupport.hpp"
|
||||||
#include "Types.h"
|
#include "Types.h"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user