mirror of
https://github.com/JakeHillion/object-introspection.git
synced 2024-09-19 11:09:05 +01:00
Update to clang/llvm 15 (#342)
Summary: Update to clang-15 compiler and libraries as clang-12 is ancient. The changes to oilgen are necessary because the new internal toolchain is being more picky about linking PIC to PIC. In certain modes we build with PIC, but try to link a non-PIC oilgen artifact. Add the ability to build the oilgen artifacts with PIC which sorts this. Reviewed By: ttreyer Differential Revision: D46220858
This commit is contained in:
parent
1d387ca880
commit
a6d74a20a6
@ -134,13 +134,14 @@ jobs:
|
||||
bison \
|
||||
build-essential \
|
||||
clang-12 \
|
||||
clang-15 \
|
||||
cmake \
|
||||
flex \
|
||||
gawk \
|
||||
libboost-all-dev \
|
||||
libbz2-dev \
|
||||
libcap2-bin \
|
||||
libclang-12-dev \
|
||||
libclang-15-dev \
|
||||
libcurl4-gnutls-dev \
|
||||
libdouble-conversion-dev \
|
||||
libdw-dev \
|
||||
@ -152,7 +153,7 @@ jobs:
|
||||
libjemalloc-dev \
|
||||
libmsgpack-dev \
|
||||
libzstd-dev \
|
||||
llvm-12-dev \
|
||||
llvm-15-dev \
|
||||
ninja-build \
|
||||
pkg-config \
|
||||
python3-setuptools
|
||||
@ -196,10 +197,10 @@ jobs:
|
||||
command: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y \
|
||||
clang-12 \
|
||||
clang-15 \
|
||||
libboost-all-dev \
|
||||
libgflags-dev \
|
||||
llvm-12-dev \
|
||||
llvm-15-dev \
|
||||
libfmt-dev \
|
||||
libjemalloc-dev
|
||||
environment:
|
||||
|
@ -73,7 +73,7 @@ FetchContent_Declare(
|
||||
FetchContent_Populate(rocksdb)
|
||||
add_custom_target(librocksdb ALL
|
||||
WORKING_DIRECTORY ${rocksdb_SOURCE_DIR}
|
||||
COMMAND cmake -G Ninja -B ${rocksdb_BINARY_DIR} -DCMAKE_BUILD_TYPE=Release -DWITH_GFLAGS=Off -DWITH_LIBURING=Off -DWITH_ZSTD=On
|
||||
COMMAND cmake -G Ninja -B ${rocksdb_BINARY_DIR} -DCMAKE_BUILD_TYPE=Release -DWITH_GFLAGS=Off -DWITH_LIBURING=Off -DWITH_ZSTD=On -DFAIL_ON_WARNINGS=Off
|
||||
COMMAND cmake --build ${rocksdb_BINARY_DIR} --target rocksdb
|
||||
BYPRODUCTS ${rocksdb_BINARY_DIR}/librocksdb.a
|
||||
COMMENT "Building RocksDB"
|
||||
@ -162,8 +162,8 @@ find_package(Boost REQUIRED COMPONENTS
|
||||
)
|
||||
message(STATUS "Linking Boost libraries: ${Boost_LIBRARIES}")
|
||||
|
||||
### LLVM and Clang - Preferring Clang 12
|
||||
find_package(LLVM 12 REQUIRED CONFIG)
|
||||
### LLVM and Clang - Preferring Clang 15
|
||||
find_package(LLVM 15 REQUIRED CONFIG)
|
||||
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
|
||||
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
|
||||
|
||||
|
@ -991,10 +991,7 @@ bool OICodeGen::enumerateChildClasses() {
|
||||
return false;
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
while (true) {
|
||||
i++;
|
||||
drgn_qualified_type* t;
|
||||
err = drgn_type_iterator_next(typesIterator, &t);
|
||||
if (err) {
|
||||
@ -1007,7 +1004,6 @@ bool OICodeGen::enumerateChildClasses() {
|
||||
if (!t) {
|
||||
break;
|
||||
}
|
||||
j++;
|
||||
|
||||
auto kind = drgn_type_kind(t->type);
|
||||
if (kind != DRGN_TYPE_CLASS && kind != DRGN_TYPE_STRUCT) {
|
||||
|
@ -28,12 +28,13 @@
|
||||
#include <glog/logging.h>
|
||||
#include <llvm/ADT/SmallVector.h>
|
||||
#include <llvm/ADT/Triple.h>
|
||||
#include <llvm/ADT/Twine.h>
|
||||
#include <llvm/Demangle/Demangle.h>
|
||||
#include <llvm/ExecutionEngine/ExecutionEngine.h>
|
||||
#include <llvm/ExecutionEngine/RTDyldMemoryManager.h>
|
||||
#include <llvm/MC/TargetRegistry.h>
|
||||
#include <llvm/Support/Host.h>
|
||||
#include <llvm/Support/Memory.h>
|
||||
#include <llvm/Support/TargetRegistry.h>
|
||||
#include <llvm/Support/TargetSelect.h>
|
||||
#include <llvm/Support/raw_os_ostream.h>
|
||||
|
||||
@ -158,7 +159,7 @@ class OIMemoryManager : public RTDyldMemoryManager {
|
||||
* failure upwards so we can shutdown cleanly.
|
||||
*/
|
||||
if (errorCode) {
|
||||
report_fatal_error("Can't allocate enough memory: " +
|
||||
report_fatal_error(llvm::Twine("Can't allocate enough memory: ") +
|
||||
errorCode.message());
|
||||
}
|
||||
|
||||
@ -490,9 +491,9 @@ bool OICompiler::compile(const std::string& code,
|
||||
compInv->getLangOpts()->Char8 = true;
|
||||
compInv->getLangOpts()->CXXOperatorNames = true;
|
||||
compInv->getLangOpts()->DoubleSquareBracketAttributes = true;
|
||||
compInv->getLangOpts()->ImplicitInt = false;
|
||||
compInv->getLangOpts()->Exceptions = true;
|
||||
compInv->getLangOpts()->CXXExceptions = true;
|
||||
compInv->getLangOpts()->Coroutines = true;
|
||||
|
||||
compInv->getPreprocessorOpts();
|
||||
compInv->getPreprocessorOpts().addRemappedFile(
|
||||
@ -540,7 +541,8 @@ bool OICompiler::compile(const std::string& code,
|
||||
std::string{"/synthetic/headers/"} + v.second,
|
||||
MemoryBuffer::getMemBuffer(v.first).release());
|
||||
}
|
||||
for (const auto& [k, _] : syntheticHeaders) {
|
||||
for (const auto& kv : syntheticHeaders) {
|
||||
const auto& k = kv.first;
|
||||
if (config.features[k]) {
|
||||
headerSearchOptions.AddPath(
|
||||
"/synthetic/headers",
|
||||
@ -552,7 +554,11 @@ bool OICompiler::compile(const std::string& code,
|
||||
compInv->getFrontendOpts().OutputFile = objectPath;
|
||||
compInv->getTargetOpts().Triple =
|
||||
llvm::Triple::normalize(llvm::sys::getProcessTriple());
|
||||
if (config.usePIC) {
|
||||
compInv->getCodeGenOpts().RelocationModel = llvm::Reloc::PIC_;
|
||||
} else {
|
||||
compInv->getCodeGenOpts().RelocationModel = llvm::Reloc::Static;
|
||||
}
|
||||
compInv->getCodeGenOpts().CodeModel = "large";
|
||||
compInv->getCodeGenOpts().OptimizationLevel = 3;
|
||||
compInv->getCodeGenOpts().NoUseJumpTables = 1;
|
||||
|
@ -48,6 +48,8 @@ class OICompiler {
|
||||
|
||||
std::vector<fs::path> userHeaderPaths{};
|
||||
std::vector<fs::path> sysHeaderPaths{};
|
||||
|
||||
bool usePIC = false;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -187,6 +187,7 @@ int OIGenerator::generate(fs::path& primaryObject, SymbolService& symbols) {
|
||||
|
||||
OICodeGen::Config generatorConfig{};
|
||||
OICompiler::Config compilerConfig{};
|
||||
compilerConfig.usePIC = pic;
|
||||
|
||||
auto features = utils::processConfigFile(configFilePath, featuresMap,
|
||||
compilerConfig, generatorConfig);
|
||||
|
@ -40,12 +40,16 @@ class OIGenerator {
|
||||
void setFailIfNothingGenerated(bool fail) {
|
||||
failIfNothingGenerated = fail;
|
||||
}
|
||||
void setUsePIC(bool pic_) {
|
||||
pic = pic_;
|
||||
}
|
||||
|
||||
private:
|
||||
std::filesystem::path outputPath;
|
||||
std::filesystem::path configFilePath;
|
||||
std::filesystem::path sourceFileDumpPath;
|
||||
bool failIfNothingGenerated;
|
||||
bool failIfNothingGenerated = false;
|
||||
bool pic = false;
|
||||
|
||||
std::unordered_map<std::string, std::string> oilStrongToWeakSymbolsMap(
|
||||
drgnplusplus::program& prog);
|
||||
|
@ -171,10 +171,7 @@ void AddChildren::enumerateChildClasses(SymbolService& symbols) {
|
||||
abort();
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
while (true) {
|
||||
i++;
|
||||
drgn_qualified_type* t;
|
||||
err = drgn_type_iterator_next(typesIterator, &t);
|
||||
if (err) {
|
||||
@ -189,7 +186,6 @@ void AddChildren::enumerateChildClasses(SymbolService& symbols) {
|
||||
if (!t) {
|
||||
break;
|
||||
}
|
||||
j++;
|
||||
|
||||
auto kind = drgn_type_kind(t->type);
|
||||
if (kind != DRGN_TYPE_CLASS && kind != DRGN_TYPE_STRUCT) {
|
||||
|
@ -63,7 +63,7 @@ system_paths = [
|
||||
"/usr/include/x86_64-linux-gnu/c++/11",
|
||||
"/usr/include/c++/11/backward",
|
||||
"/usr/local/include",
|
||||
"/usr/lib/llvm-12/lib/clang/12.0.1/include",
|
||||
"/usr/lib/llvm-15/lib/clang/15.0.7/include",
|
||||
"/usr/include/x86_64-linux-gnu",
|
||||
"/usr/include",
|
||||
]
|
||||
|
@ -39,12 +39,6 @@ definitions = '''
|
||||
char c;
|
||||
alignas(32) char c32;
|
||||
};
|
||||
|
||||
enum class alignas(16) AlignedEnum16 : int8_t {
|
||||
Val1,
|
||||
Val2,
|
||||
Val3,
|
||||
};
|
||||
'''
|
||||
[cases]
|
||||
[cases.wrapper_struct]
|
||||
@ -212,19 +206,3 @@ definitions = '''
|
||||
{"typeName": "char", "staticSize": 1, "exclusiveSize": 1},
|
||||
{"typeName": "char", "staticSize": 1, "exclusiveSize": 1}
|
||||
]}]}]'''
|
||||
[cases.wrapper_enum]
|
||||
param_types = ["const Wrapper<AlignedEnum16>&"]
|
||||
setup = "return {};"
|
||||
expect_json = '''[
|
||||
{"staticSize": 32, "exclusiveSize": 30, "members": [
|
||||
{"typeName": "int8_t", "staticSize": 1, "exclusiveSize": 1},
|
||||
{"typeName": "AlignedEnum16", "staticSize": 1, "exclusiveSize": 1}
|
||||
]}]'''
|
||||
[cases.container_enum]
|
||||
skip = "container alignment is broken (#143)"
|
||||
param_types = ["const std::optional<AlignedEnum16>&"]
|
||||
setup = "return {};"
|
||||
expect_json = '''[
|
||||
{"staticSize": 32, "exclusiveSize": 31, "members": [
|
||||
{"typeName": "AlignedEnum16", "staticSize": 1, "exclusiveSize": 1}
|
||||
]}]'''
|
||||
|
@ -310,13 +310,6 @@ int main(int argc, char* argv[]) {
|
||||
}
|
||||
|
||||
std::cout << "mapOfWords #elements: " << mapOfWords.size() << std::endl;
|
||||
|
||||
int size = 0;
|
||||
|
||||
for (auto it = mapOfWords.begin(); it != mapOfWords.end(); ++it) {
|
||||
size += (int)it->first.size();
|
||||
}
|
||||
|
||||
std::cout << "mapOfWords map addr = " << &mapOfWords << std::endl;
|
||||
std::cout << "nameList vector addr = " << &nameList << std::endl;
|
||||
|
||||
|
@ -232,13 +232,6 @@ int main(int argc, char* argv[]) {
|
||||
}
|
||||
|
||||
std::cout << "mapOfWords #elements: " << mapOfWords.size() << std::endl;
|
||||
|
||||
int size = 0;
|
||||
|
||||
for (auto it = mapOfWords.begin(); it != mapOfWords.end(); ++it) {
|
||||
size += (int)it->first.size();
|
||||
}
|
||||
|
||||
std::cout << "mapOfWords map addr = " << &mapOfWords << std::endl;
|
||||
std::cout << "nameList vector addr = " << &nameList << std::endl;
|
||||
|
||||
|
@ -37,6 +37,8 @@ constexpr static OIOpts opts{
|
||||
"Write generated code to a file (for debugging)."},
|
||||
OIOpt{'e', "exit-code", no_argument, nullptr,
|
||||
"Return a bad exit code if nothing is generated."},
|
||||
OIOpt{'p', "pic", no_argument, nullptr,
|
||||
"Generate position independent code."},
|
||||
};
|
||||
|
||||
void usage() {
|
||||
@ -59,6 +61,7 @@ int main(int argc, char* argv[]) {
|
||||
fs::path configFilePath = "/usr/local/share/oi/base.oid.toml";
|
||||
fs::path sourceFileDumpPath = "";
|
||||
bool exitCode = false;
|
||||
bool pic = false;
|
||||
|
||||
int c;
|
||||
while ((c = getopt_long(argc, argv, opts.shortOpts(), opts.longOpts(),
|
||||
@ -79,6 +82,9 @@ int main(int argc, char* argv[]) {
|
||||
case 'e':
|
||||
exitCode = true;
|
||||
break;
|
||||
case 'p':
|
||||
pic = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -100,6 +106,7 @@ int main(int argc, char* argv[]) {
|
||||
oigen.setConfigFilePath(std::move(configFilePath));
|
||||
oigen.setSourceFileDumpPath(sourceFileDumpPath);
|
||||
oigen.setFailIfNothingGenerated(exitCode);
|
||||
oigen.setUsePIC(pic);
|
||||
|
||||
SymbolService symbols(primaryObject);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user