Commit 72f1c293 authored by David Carlier's avatar David Carlier Committed by Facebook GitHub Bot

FreeBSD and/or clang build fix. (#1317)

Summary:
clang being more strict with obsolete C++14 api, has
completely disabled them in this context.
Pull Request resolved: https://github.com/facebook/folly/pull/1317

Reviewed By: luciang, markisaa

Differential Revision: D20154780

Pulled By: yfeldblum

fbshipit-source-id: 1ff36fecd3406802c3f393dfdd5dbe2f30656567
parent db0e476d
......@@ -550,3 +550,13 @@ constexpr auto kCpplibVer = 0;
#define FOLLY_HAS_STRING_VIEW 0
#endif
#endif // __has_include
#if defined(__linux__)
#define FOLLY_ELF_NATIVE_CLASS __ELF_NATIVE_CLASS
#elif defined(__FreeBSD__)
#if defined(__LP64__)
#define FOLLY_ELF_NATIVE_CLASS 64
#else // __linux__
#define FOLLY_ELF_NATIVE_CLASS 32
#endif
#endif // __linux__
......@@ -26,6 +26,7 @@
namespace __cxxabiv1 {
#if !defined(__FreeBSD__)
struct __cxa_exception {
std::type_info* exceptionType;
void (*exceptionDestructor)(void*);
......@@ -52,5 +53,6 @@ extern "C" {
__cxa_eh_globals* __cxa_get_globals(void) noexcept;
__cxa_eh_globals* __cxa_get_globals_fast(void) noexcept;
}
#endif
} // namespace __cxxabiv1
......@@ -16,6 +16,7 @@
#include <folly/experimental/exception_tracer/ExceptionTracer.h>
#include <cstdlib>
#include <exception>
#include <iostream>
......@@ -200,6 +201,7 @@ std::vector<ExceptionInfo> getCurrentExceptions() {
return exceptions;
}
#if FOLLY_USE_LIBSTDCPP
namespace {
std::terminate_handler origTerminate = abort;
......@@ -238,6 +240,7 @@ void installHandlers() {
};
static Once once;
}
#endif
} // namespace exception_tracer
} // namespace folly
......@@ -380,7 +380,7 @@ bool Dwarf::Section::next(folly::StringPiece& chunk) {
}
folly::StringPiece Dwarf::getSection(const char* name) const {
const ElfW(Shdr)* elfSection = elf_->getSectionByName(name);
const ElfShdr* elfSection = elf_->getSectionByName(name);
if (!elfSection) {
return {};
}
......
......@@ -211,7 +211,7 @@ ElfFile::OpenResult ElfFile::init() noexcept {
auto& elfHeader = this->elfHeader();
#define EXPECTED_CLASS P1(ELFCLASS, __ELF_NATIVE_CLASS)
#define EXPECTED_CLASS P1(ELFCLASS, FOLLY_ELF_NATIVE_CLASS)
#define P1(a, b) P2(a, b)
#define P2(a, b) a##b
// Validate ELF class (32/64 bits)
......
......@@ -35,12 +35,21 @@
namespace folly {
namespace symbolizer {
#if defined(__linux__)
using ElfAddr = ElfW(Addr);
using ElfEhdr = ElfW(Ehdr);
using ElfOff = ElfW(Off);
using ElfPhdr = ElfW(Phdr);
using ElfShdr = ElfW(Shdr);
using ElfSym = ElfW(Sym);
#elif defined(__FreeBSD__)
using ElfAddr = Elf_Addr;
using ElfEhdr = Elf_Ehdr;
using ElfOff = Elf_Off;
using ElfPhdr = Elf_Phdr;
using ElfShdr = Elf_Shdr;
using ElfSym = Elf_Sym;
#endif
/**
* ELF file parser.
......
......@@ -361,8 +361,15 @@ void dumpSignalInfo(int signum, siginfo_t* siginfo) {
printDec(getpid());
print(" (pthread TID ");
printHex((uint64_t)pthread_self());
#if defined(__linux__)
print(") (linux TID ");
printDec(syscall(__NR_gettid));
#elif defined(__FreeBSD__)
long tid = 0;
syscall(432, &tid);
print(") (freebsd TID ");
printDec(tid);
#endif
// Kernel-sourced signals don't give us useful info for pid/uid.
if (siginfo->si_code <= 0) {
......
......@@ -189,7 +189,7 @@ void Symbolizer::symbolize(
// Get the unrelocated, ELF-relative address by normalizing via the
// address at which the object is loaded.
auto const adjusted = addr - lmap->l_addr;
auto const adjusted = addr - reinterpret_cast<uintptr_t>(lmap->l_addr);
size_t numInlined = 0;
if (elfFile->getSectionContainingAddress(adjusted)) {
if (mode_ == LocationInfoMode::FULL_WITH_INLINE &&
......@@ -374,7 +374,7 @@ void SymbolizePrinter::println(
namespace {
int getFD(const std::ios& stream) {
#if defined(__GNUC__) && FOLLY_HAS_RTTI
#if FOLLY_USE_LIBSTDCPP && FOLLY_HAS_RTTI
std::streambuf* buf = stream.rdbuf();
using namespace __gnu_cxx;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment