Skip to content
This repository was archived by the owner on Nov 6, 2022. It is now read-only.

Enable warnings, enable warnings are erros, fix errors #4

Merged
merged 1 commit into from
Jan 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libunwind/README_RUST_SGX.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Initial Fork has been made from 5.0 release of llvm (commit: 6a075b6de4)
* `cd where you want to build libunwind`
* `mkdir build`
* `cd build`
* `cmake -DCMAKE_BUILD_TYPE="RELEASE" -DRUST_SGX=1 -G "Unix Makefiles" -DLLVM_PATH=<path/to/llvm> <path/to/libunwind>`
* `cmake -DCMAKE_BUILD_TYPE="RELEASE" -DRUST_SGX=1 -G "Unix Makefiles" -DLLVM_ENABLE_WARNINGS=1 -DLIBUNWIND_ENABLE_WERROR=1 -DLIBUNWIND_ENABLE_PEDANTIC=0 -DLLVM_PATH=<path/to/llvm> <path/to/libunwind>`
* `-DCMAKE_BUILD_TYPE="RELEASE"` could be removed to enable debug logs of libunwind.

### Build:
Expand Down
6 changes: 4 additions & 2 deletions libunwind/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,13 @@ endif()
if (RUST_SGX)
# Compile Flags
add_definitions(-DRUST_SGX)
add_definitions(-DU_FORTIFY_SOURCE)
add_definitions(-D_FORTIFY_SOURCE=0)
add_definitions(-D__NO_STRING_INLINES)
add_definitions(-D__NO_MATH_INLINES)
add_definitions(-D_LIBUNWIND_IS_BAREMETAL)
# Can't use add_definitions because CMake will reorder these arguments
list(APPEND LIBUNWIND_COMPILE_FLAGS -U_FORTIFY_SOURCE)
list(APPEND LIBUNWIND_COMPILE_FLAGS -D_FORTIFY_SOURCE=0)

list(APPEND LIBUNWIND_COMPILE_FLAGS -fno-stack-protector)
list(APPEND LIBUNWIND_COMPILE_FLAGS -ffreestanding)
list(APPEND LIBUNWIND_COMPILE_FLAGS -fexceptions)
Expand Down
2 changes: 2 additions & 0 deletions libunwind/src/UnwindLevel1-gcc-ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
//
//===----------------------------------------------------------------------===//

#pragma GCC diagnostic ignored "-Wstrict-aliasing"

#include <inttypes.h>
#include <stdbool.h>
#include <stdint.h>
Expand Down
3 changes: 3 additions & 0 deletions libunwind/src/UnwindLevel1.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
// to export these functions from libunwind.so as well.
#define _LIBUNWIND_UNWIND_LEVEL1_EXTERNAL_LINKAGE 1

#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
#pragma GCC diagnostic ignored "-Wempty-body"

#include <inttypes.h>
#include <stdint.h>
#include <stdbool.h>
Expand Down
12 changes: 6 additions & 6 deletions libunwind/src/UnwindRustSgx.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#define max_log 256


__attribute__((weak)) struct _IO_FILE *stderr = -1;
__attribute__((weak)) struct _IO_FILE *stderr = (_IO_FILE *)-1;

static int vwrite_err(const char *format, va_list ap)
{
Expand Down Expand Up @@ -55,7 +55,7 @@ __attribute__((weak)) int fprintf (FILE *__restrict __stream,
return -1;
} else {
va_list args;
int ret = 0;
ret = 0;
va_start(args, __format);
ret += vwrite_err(__format, args);
va_end(args);
Expand Down Expand Up @@ -102,7 +102,7 @@ extern uint64_t TEXT_BASE;
extern uint64_t TEXT_SIZE;
extern uint64_t EH_FRM_HDR_BASE;
extern uint64_t EH_FRM_HDR_SIZE;
extern void IMAGE_BASE;
extern char IMAGE_BASE;

typedef Elf64_Phdr Elf_Phdr;
int
Expand All @@ -121,7 +121,7 @@ dl_iterate_phdr (int (*callback) (struct dl_phdr_info *,

memset(pinfo, 0, sizeof(*pinfo));

pinfo->dlpi_addr = &IMAGE_BASE;
pinfo->dlpi_addr = (ElfW(Addr))&IMAGE_BASE;
pinfo->dlpi_phnum = 2;

pinfo->dlpi_phdr = phdr;
Expand Down Expand Up @@ -154,7 +154,7 @@ void *libuw_malloc(size_t size)
{
struct libwu_rs_alloc_meta *meta;
size_t alloc_size = size + sizeof(struct libwu_rs_alloc_meta);
meta = (void *)__rust_alloc(alloc_size, sizeof(size_t));
meta = (void *)__rust_c_alloc(alloc_size, sizeof(size_t));
if (!meta) {
return NULL;
}
Expand All @@ -169,5 +169,5 @@ void libuw_free(void *p)
return;
}
meta = META_FROM_PTR(p);
__rust_dealloc((unsigned char *)meta, meta->alloc_size, sizeof(size_t));
__rust_c_dealloc((unsigned char *)meta, meta->alloc_size, sizeof(size_t));
}
11 changes: 5 additions & 6 deletions libunwind/src/UnwindRustSgx.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

#ifdef RUST_SGX

#undef _GNU_SOURCE
#define _GNU_SOURCE
#include <link.h>
#include <stdarg.h>
Expand Down Expand Up @@ -70,22 +71,18 @@ extern "C" {
#undef pthread_rwlock_rdlock
#undef pthread_rwlock_wrlock
#undef pthread_rwlock_unlock
#undef PTHREAD_RWLOCK_INITIALIZER

#define pthread_rwlock_t RWLock
#define PTHREAD_RWLOCK_INITIALIZER RWLOCK_INIT


#define pthread_rwlock_rdlock __rust_rwlock_rdlock
#define pthread_rwlock_wrlock __rust_rwlock_wrlock
#define pthread_rwlock_unlock __rust_rwlock_unlock

#define PTHREAD_RWLOCK_INITIALIZER RWLOCK_INIT

#define malloc libuw_malloc
#define free libuw_free

#ifdef dl_iterate_phdr
#undef dl_iterate_phdr
#endif
#define dl_iterate_phdr libuw_dl_iterate_phdr

#ifdef __cplusplus
Expand All @@ -96,6 +93,8 @@ void *libuw_malloc(size_t size);

void libuw_free(void *p);

struct dl_phdr_info;

int
libuw_dl_iterate_phdr (int (*callback) (struct dl_phdr_info *,
size_t, void *), void *data);
Expand Down
6 changes: 6 additions & 0 deletions libunwind/src/UnwindRustSgxSnprintf.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
* on all source code distributions
*/

#pragma GCC diagnostic ignored "-Wconversion"
#pragma GCC diagnostic ignored "-Wdiscarded-qualifiers"
#pragma GCC diagnostic ignored "-Wfloat-conversion"
#pragma GCC diagnostic ignored "-Wsign-conversion"
#pragma GCC diagnostic ignored "-Wstrict-overflow"

/**************************************************************
* Original:
* Patrick Powell Tue Apr 11 09:48:21 PDT 1995
Expand Down
6 changes: 6 additions & 0 deletions libunwind/src/libunwind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
//
//===----------------------------------------------------------------------===//

#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
#pragma GCC diagnostic ignored "-Wmissing-braces"
#pragma GCC diagnostic ignored "-Wsign-conversion"
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
#pragma GCC diagnostic ignored "-Wstrict-overflow"

#include <libunwind.h>

#ifndef NDEBUG
Expand Down