diff --git a/CMakeLists.txt b/CMakeLists.txt index f1991e2f1595353316a84053e5d74d17c6d13af5..c757d3b55333cd60b9a96a7c436e4962b841fda3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 2.6) project(tarantool) include(CheckLibraryExists) include(CheckIncludeFile) +include(CheckCCompilerFlag) find_program(ECHO echo) find_program(CAT cat) find_program(GIT git) @@ -43,6 +44,12 @@ else() message (FATAL_ERROR "Unsupported platform -- ${CMAKE_SYSTEM_NAME}") endif() +# +# Some versions of GNU libc define non-portable __libc_stack_end +# which we use to determine the end (or beginning, actually) of +# stack. Find whether or not it's present. +check_library_exists("" __libc_stack_end "" HAVE_LIBC_STACK_END) + # # Tarantool uses 'coro' (coroutines) library # to implement # cooperative multi-tasking. Since coro.h is included @@ -140,6 +147,7 @@ with gcc. If GNU binutils and binutils-dev libraries are installed, backtrace is output with resolved function (symbol) names. Otherwise only frame addresses are printed." ${CMAKE_COMPILER_IS_GNUCC}) +set (HAVE_BFD False) if (ENABLE_BACKTRACE) if (NOT ${CMAKE_COMPILER_IS_GNUCC} OR NOT (${CMAKE_SYSTEM_PROCESSOR} MATCHES "86")) @@ -151,7 +159,7 @@ if (ENABLE_BACKTRACE) check_library_exists (bfd bfd_init "" HAVE_BFD_LIB) check_include_file(bfd.h HAVE_BFD_H) if (HAVE_BFD_LIB AND HAVE_BFD_H) - set (HAVE_BFD 1) + set (HAVE_BFD True) message (STATUS "Found GNU bfd headers and libs, enabling symbol ") message (STATUS "resolve in backtraces.") elseif (NOT HAVE_BFD_LIB) diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index 7d0ef6126cd267aab30b685564bdd176525f2fa7..391c0184a4a02bf8c3208f1338133fcf6d8b932d 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -3,8 +3,12 @@ # add_library(ev tarantool_ev.c) -set_source_files_properties(tarantool_ev.c - PROPERTIES COMPILE_FLAGS "-Wno-unused-result") +check_c_compiler_flag ("-Wno-unused-result" gcc_has_wno_unused_result) + +if (gcc_has_wno_unused_result) + set_source_files_properties(tarantool_ev.c + PROPERTIES COMPILE_FLAGS "-Wno-unused-result") +endif() if (TARGET_OS_LINUX) # diff --git a/core/log_io.c b/core/log_io.c index 6c5df8ee42b45319eea5f40d5cc9d83f09545847..b4f4f97ce1f8360a14d595f06aae813c116d7d47 100644 --- a/core/log_io.c +++ b/core/log_io.c @@ -596,7 +596,8 @@ inprogress_log_unlink(char *filename) assert(strcmp(suffix, inprogress_suffix) == 0); #endif if (unlink(filename) != 0) { - if (errno == ENONET) + /* Don't panic if there is no such file. */ + if (errno == ENOENT) return 0; say_syserror("can't unlink %s", filename); diff --git a/core/tarantool.c b/core/tarantool.c index 6964498f288d883b521016ace37b686022deaf8d..67c74a29fac8575e16ab409323dea99833b90d02 100644 --- a/core/tarantool.c +++ b/core/tarantool.c @@ -313,6 +313,17 @@ main(int argc, char **argv) #endif const char *cfg_paramname = NULL; +#ifndef HAVE_LIBC_STACK_END +/* + * GNU libc provides a way to get at the top of the stack. This + * is, of course, not standard and doesn't work on non-GNU + * systems, such as FreeBSD. But as far as we're concerned, argv + * is at the top of the main thread's stack, so save the address + * of it. + */ + __libc_stack_end = (void*) &argv; +#endif + master_pid = getpid(); stat_init(); palloc_init(); diff --git a/core/util.c b/core/util.c index d38f8835b73116152f28dc5a36f002a88b3c26a7..9e53cabf3e6c0f81ac2d941a5fcc62195c5ad4df 100644 --- a/core/util.c +++ b/core/util.c @@ -42,6 +42,10 @@ #include <util.h> #include <fiber.h> +#ifndef HAVE_LIBC_STACK_END +void *__libc_stack_end; +#endif + void close_all_xcpt(int fdc, ...) { diff --git a/include/config.h.cmake b/include/config.h.cmake index cadf475ba9ba2d40add64417f94cb54efa300d49..e8cad3c90d9f6cdabec939d31d50122ad853aaa1 100644 --- a/include/config.h.cmake +++ b/include/config.h.cmake @@ -31,6 +31,10 @@ * Set if the system has bfd.h header and GNU bfd library. */ #cmakedefine HAVE_BFD 1 +/* + * Set if this is a GNU system and libc has __libc_stack_end. + */ +#cmakedefine HAVE_LIBC_STACK_END 1 /* * vim: syntax=c */ diff --git a/test/box/show.result b/test/box/show.result index 0811fbee1851e36fd991371c7f32fc0354300054..53f2d43cef6f59e3852ba4cc28392c3c335955f1 100644 --- a/test/box/show.result +++ b/test/box/show.result @@ -35,7 +35,7 @@ configuration: slab_alloc_factor: "2" work_dir: (null) pid_file: "box.pid" - logger: "tee --append tarantool.log" + logger: "tee -a tarantool.log" logger_nonblock: "1" io_collect_interval: "0" backlog: "1024" diff --git a/test/box/tarantool.cfg b/test/box/tarantool.cfg index d7cd0fe80ccd4940e6b324918043eabbf43d45a9..67438804646d0b37577ac35932d98eced24e6c66 100644 --- a/test/box/tarantool.cfg +++ b/test/box/tarantool.cfg @@ -2,7 +2,10 @@ slab_alloc_arena = 0.1 pid_file = "box.pid" -logger="tee --append tarantool.log" + +# Use -a not -a to work correctly on FreeBSD +# +logger="tee -a tarantool.log" primary_port = 33013 secondary_port = 33014 diff --git a/test/box/tarantool_bad2.cfg b/test/box/tarantool_bad2.cfg index 0d03bfde3b38b7e1cce9c5d2b2a40811060bbddf..699a08bcd133632fc25b7861ea50945efaec1e8c 100644 --- a/test/box/tarantool_bad2.cfg +++ b/test/box/tarantool_bad2.cfg @@ -2,7 +2,7 @@ slab_alloc_arena = 0.1 pid_file = "box.pid" -logger="tee --append tarantool.log" +logger="tee -a tarantool.log" #primary_port = 33013 secondary_port = 33014 diff --git a/test/box/tarantool_bad3.cfg b/test/box/tarantool_bad3.cfg index 8c1d14c3c6e43ed63617f14700c5f8c2b2719ff7..934acbe01dca14b1fe733f5bfad0a06e825c8251 100644 --- a/test/box/tarantool_bad3.cfg +++ b/test/box/tarantool_bad3.cfg @@ -2,7 +2,7 @@ slab_alloc_arena = 0.1 pid_file = "box.pid" -logger="tee --append tarantool.log" +logger="tee -a tarantool.log" primary_port = 33013 secondary_port = 33014 diff --git a/test/box/tarantool_bad4.cfg b/test/box/tarantool_bad4.cfg index 67b9c893b0ae0e5f691d090a1bf3a6150648a876..305de0e9a6fd4d62f35427beb53aa7f35d8ddb15 100644 --- a/test/box/tarantool_bad4.cfg +++ b/test/box/tarantool_bad4.cfg @@ -2,7 +2,7 @@ slab_alloc_arena = 0.1 pid_file = "box.pid" -logger="tee --append tarantool.log" +logger="tee -a tarantool.log" primary_port = 33013 secondary_port = 33014 diff --git a/test/box/tarantool_bad5.cfg b/test/box/tarantool_bad5.cfg index 1390839277b1fa49ed953c4aef3d73c269080a9b..7854bd4d37d32105a57a8654e0e27fe950ba5851 100644 --- a/test/box/tarantool_bad5.cfg +++ b/test/box/tarantool_bad5.cfg @@ -2,7 +2,7 @@ slab_alloc_arena = 0.1 pid_file = "box.pid" -logger="tee --append tarantool.log" +logger="tee -a tarantool.log" primary_port = 33013 secondary_port = 33014 diff --git a/test/box/tarantool_good.cfg b/test/box/tarantool_good.cfg index d7cd0fe80ccd4940e6b324918043eabbf43d45a9..32f2c827c3228404bf64dff3a2a6fec58b0794a7 100644 --- a/test/box/tarantool_good.cfg +++ b/test/box/tarantool_good.cfg @@ -2,7 +2,7 @@ slab_alloc_arena = 0.1 pid_file = "box.pid" -logger="tee --append tarantool.log" +logger="tee -a tarantool.log" primary_port = 33013 secondary_port = 33014