From ab6a37f1dc291827998318aa0b1e3f177b138a76 Mon Sep 17 00:00:00 2001 From: Alexei Starovoitov Date: Tue, 9 Jun 2015 12:50:42 -0700 Subject: [PATCH] fix build with gcc < 4.9 Signed-off-by: Alexei Starovoitov --- src/cc/CMakeLists.txt | 4 +++- src/cc/kbuild_helper.h | 9 +++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/cc/CMakeLists.txt b/src/cc/CMakeLists.txt index 1c5c460..804204f 100644 --- a/src/cc/CMakeLists.txt +++ b/src/cc/CMakeLists.txt @@ -9,7 +9,9 @@ BISON_TARGET(Parser parser.yy ${CMAKE_CURRENT_BINARY_DIR}/parser.yy.cc COMPILE_F FLEX_TARGET(Lexer lexer.ll ${CMAKE_CURRENT_BINARY_DIR}/lexer.ll.cc COMPILE_FLAGS "--c++ --o lexer.ll.cc") ADD_FLEX_BISON_DEPENDENCY(Lexer Parser) -set(CMAKE_SHARED_LINKER_FLAGS "-static-libstdc++ -Wl,--exclude-libs=ALL") +# if gcc 4.9 or higher is used, static libstdc++ is a good option +#set(CMAKE_SHARED_LINKER_FLAGS "-static-libstdc++ -Wl,--exclude-libs=ALL") +set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--exclude-libs=ALL") add_library(bpfprog SHARED bpf_common.cc bpf_module.cc codegen_llvm.cc node.cc parser.cc printer.cc type_check.cc libbpf.c b_frontend_action.cc diff --git a/src/cc/kbuild_helper.h b/src/cc/kbuild_helper.h index 416d25c..6cb505c 100644 --- a/src/cc/kbuild_helper.h +++ b/src/cc/kbuild_helper.h @@ -57,6 +57,10 @@ class DirStack { char cwd_[256]; }; +static int ftw_cb(const char *path, const struct stat *, int) { + return ::remove(path); +} + // Scoped class to manage the creation/deletion of tmpdirs class TmpDir { public: @@ -69,10 +73,7 @@ class TmpDir { ok_ = true; } ~TmpDir() { - auto fn = [] (const char *path, const struct stat *, int) -> int { - return ::remove(path); - }; - if (::ftw(prefix_.c_str(), fn, 20) < 0) + if (::ftw(prefix_.c_str(), ftw_cb, 20) < 0) ::perror("ftw"); else ::remove(prefix_.c_str()); -- 2.7.4