diff --git a/build/unix/compiledata.sh b/build/unix/compiledata.sh index 7ebf12343ff73..f0f5946e6dcd9 100755 --- a/build/unix/compiledata.sh +++ b/build/unix/compiledata.sh @@ -58,7 +58,7 @@ CXXFLAGS=`echo $CXXFLAGS | sed 's/-Iinclude //' ` # Remove the flags turning warnings into errors or extending # the number of warnings. -CXXFLAGS=`echo $CXXFLAGS | sed -e 's/-Werror //g' -e 's/-Werror=\S* //g' -e 's/-Wall //g' -e 's/-Wshadow //g' ` +CXXFLAGS=`echo $CXXFLAGS | sed -e 's/-Werror //g' -e 's/-Werror=[^[:space:]]* //g' -e 's/-Wall //g' -e 's/-Wshadow //g' ` # Determine the compiler version BXX="`basename $CXX`" diff --git a/cmake/modules/CheckCompiler.cmake b/cmake/modules/CheckCompiler.cmake index a45d721e10d6d..015d74f52566d 100644 --- a/cmake/modules/CheckCompiler.cmake +++ b/cmake/modules/CheckCompiler.cmake @@ -204,6 +204,8 @@ endif() #---Setup details depending on the major platform type---------------------------------------------- if(CMAKE_SYSTEM_NAME MATCHES Linux) include(SetUpLinux) +elseif(CMAKE_SYSTEM_NAME MATCHES FreeBSD) + include(SetUpFreeBSD) elseif(APPLE) include(SetUpMacOS) elseif(WIN32) diff --git a/cmake/modules/SetUpFreeBSD.cmake b/cmake/modules/SetUpFreeBSD.cmake new file mode 100644 index 0000000000000..52c97d28f2971 --- /dev/null +++ b/cmake/modules/SetUpFreeBSD.cmake @@ -0,0 +1,97 @@ +# Copyright (C) 1995-2023, Rene Brun and Fons Rademakers. +# All rights reserved. +# +# For the licensing terms see $ROOTSYS/LICENSE. +# For the list of contributors see $ROOTSYS/README/CREDITS. + +set(ROOT_PLATFORM freebsd) + +if(CMAKE_SYSTEM_PROCESSOR MATCHES x86_64 OR CMAKE_SYSTEM_PROCESSOR MATCHES amd64) + set(ROOT_ARCHITECTURE freebsdamd64) +elseif(CMAKE_SYSTEM_PROCESSOR MATCHES i686) + set(FP_MATH_FLAGS "-msse2 -mfpmath=sse") + set(ROOT_ARCHITECTURE freebsdi686) +elseif(CMAKE_SYSTEM_PROCESSOR MATCHES aarch64) + set(ROOT_ARCHITECTURE freebsdarm64) +elseif(CMAKE_SYSTEM_PROCESSOR MATCHES arm) + set(ROOT_ARCHITECTURE freebsdarm) +elseif(CMAKE_SYSTEM_PROCESSOR MATCHES ppc64 OR + CMAKE_SYSTEM_PROCESSOR MATCHES powerpc64 OR + CMAKE_SYSTEM_PROCESSOR MATCHES powerpc64le) + set(ROOT_ARCHITECTURE freebsdppc64) +elseif(CMAKE_SYSTEM_PROCESSOR MATCHES s390x) + set(ROOT_ARCHITECTURE freebsds390x) +elseif(CMAKE_SYSTEM_PROCESSOR MATCHES s390) + set(ROOT_ARCHITECTURE freebsds390) +elseif(CMAKE_SYSTEM_PROCESSOR MATCHES riscv64) + set(ROOT_ARCHITECTURE freebsdriscv64) +else() + message(FATAL_ERROR "Unknown processor: ${CMAKE_SYSTEM_PROCESSOR}") +endif() + +# JIT must be able to resolve symbols from all ROOT binaries. +set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -rdynamic") + +# Set developer flags +if(dev) + # Warnings are errors. + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror") + + # Do not relink just because a dependent .so has changed. + # I.e. relink only if a header included by the libs .o-s has changed, + # whether or not that header "belongs" to a different .so. + set(CMAKE_LINK_DEPENDS_NO_SHARED On) + + # Split debug info for faster builds. + if(NOT gnuinstall) + # We won't install DWARF files. + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -gsplit-dwarf") + endif() + + if(_BUILD_TYPE_UPPER MATCHES "DEB") + message(STATUS "Using ld.lld linker with gdb-index") + set(GDBINDEX "-Wl,--gdb-index") + else() + message(STATUS "Using ld.lld linker without gdb-index") + endif() + + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${GDBINDEX}") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GDBINDEX}") + set(LLVM_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${GDBINDEX}") + set(LLVM_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GDBINDEX}") +endif() + +if(CMAKE_COMPILER_IS_GNUCXX) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pipe ${FP_MATH_FLAGS} -Wshadow -Wall -W -Woverloaded-virtual -fsigned-char") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pipe -Wall -W") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -std=legacy") + + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined -Wl,--hash-style=\"both\"") + + if(asan) + # See also core/sanitizer/README.md for what's happening. + execute_process(COMMAND ${CMAKE_CXX_COMPILER} --print-file-name=libclang_rt.asan-x86_64.so OUTPUT_VARIABLE ASAN_RUNTIME_LIBRARY OUTPUT_STRIP_TRAILING_WHITESPACE) + set(ASAN_EXTRA_CXX_FLAGS -fsanitize=address -fno-omit-frame-pointer -fsanitize-recover=address) + set(ASAN_EXTRA_SHARED_LINKER_FLAGS "-fsanitize=address -z undefs") + set(ASAN_EXTRA_EXE_LINKER_FLAGS "-fsanitize=address -z undefs -Wl,--undefined=__asan_default_options -Wl,--undefined=__lsan_default_options -Wl,--undefined=__lsan_default_suppressions") + endif() + +elseif(CMAKE_CXX_COMPILER_ID STREQUAL Clang) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pipe ${FP_MATH_FLAGS} -Wall -W -Woverloaded-virtual -fsigned-char") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pipe -Wall -W") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -std=legacy") + + if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wshadow") + endif() + + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined") + + if(asan) + # See also core/sanitizer/README.md for what's happening. + execute_process(COMMAND ${CMAKE_CXX_COMPILER} --print-file-name=libclang_rt.asan-x86_64.so OUTPUT_VARIABLE ASAN_RUNTIME_LIBRARY OUTPUT_STRIP_TRAILING_WHITESPACE) + set(ASAN_EXTRA_CXX_FLAGS -fsanitize=address -fno-omit-frame-pointer -fsanitize-address-use-after-scope) + set(ASAN_EXTRA_SHARED_LINKER_FLAGS "-fsanitize=address -static-libsan -z undefs") + set(ASAN_EXTRA_EXE_LINKER_FLAGS "-fsanitize=address -static-libsan -z undefs -Wl,--undefined=__asan_default_options -Wl,--undefined=__lsan_default_options -Wl,--undefined=__lsan_default_suppressions") + endif() +endif() diff --git a/config/root-config.in b/config/root-config.in index a7756c593d7ad..a9e2d9523d9aa 100755 --- a/config/root-config.in +++ b/config/root-config.in @@ -262,20 +262,10 @@ linuxriscv64) # RISC-V Linux auxlibs="-lm -ldl -rdynamic" ;; -freebsd) - # FreeBSD with libc5 +freebsd*) + # FreeBSD auxcflags="${cxxversionflag}" - auxlibs="-lm -lg++" - ;; -freebsd4) - # FreeBSD 4 with glibc - auxcflags="${cxxversionflag}" - auxlibs="-lm -lstdc++" - ;; -freebsd5|freebsd7) - # FreeBSD 5/7 with glibc - auxcflags="${cxxversionflag}" - auxlibs="-lm -lstdc++" + auxlibs="-lm" ;; openbsd) # OpenBSD with libc @@ -368,7 +358,21 @@ esac ### compiler dependent settings ### case $arch in -freebsd* | openbsd* | linux*) +freebsd*) + auxcflags="-pthread -D_REENTRANT $auxcflags" + auxlibs="-pthread $auxlibs" + + for f in $features ; do + if test "x$f" = "xrpath" ; then + auxlibs="-Wl,-rpath,$libdir $auxlibs" + fi + if test "x$f" = "xlibcxx" ; then + auxcflags="-stdlib=libc++ $auxcflags" + auxlibs="-stdlib=libc++ $auxlibs" + fi + done + ;; +openbsd* | linux*) auxcflags="-pthread $auxcflags" auxlibs="-pthread $auxlibs" @@ -784,9 +788,12 @@ while test $# -gt 0; do ### number of available cores ncpu=1 case $arch in - freebsd* | openbsd* | linux*) + openbsd* | linux*) ncpu=$(awk '/^processor/ {++n} END {print n}' /proc/cpuinfo) ;; + freebsd*) + ncpu=$(sysctl -n hw.ncpu) + ;; macosx*) ncpu=$(sysctl -n hw.ncpu) ;; diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index 7c16cd54063dd..627b09346fbd5 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -81,6 +81,10 @@ target_link_libraries(Core ${ROOT_ATOMIC_LIBS} ) +if (CMAKE_SYSTEM_NAME MATCHES FreeBSD) + target_link_libraries(Core PUBLIC util procstat) +endif() + target_include_directories(Core PUBLIC $ ) diff --git a/core/dictgen/src/rootcling_impl.cxx b/core/dictgen/src/rootcling_impl.cxx index f56ce23b7ac0c..07f7385b31193 100644 --- a/core/dictgen/src/rootcling_impl.cxx +++ b/core/dictgen/src/rootcling_impl.cxx @@ -54,6 +54,14 @@ #include #endif +#ifdef R__FBSD +#include +#include +#include +#include +#include +#endif // R__FBSD + #if !defined(R__WIN32) #include #include @@ -207,6 +215,19 @@ const char *GetExePath() exepath = buf; } #endif +#if defined(R__FBSD) + procstat* ps = procstat_open_sysctl(); // + kinfo_proc* kp = kinfo_getproc(getpid()); + + if (kp!=NULL) { + char path_str[PATH_MAX] = ""; + procstat_getpathname(ps, kp, path_str, sizeof(path_str)); + exepath = path_str; + } + + free(kp); + procstat_close(ps); +#endif #ifdef _WIN32 char *buf = new char[MAX_MODULE_NAME32 + 1]; ::GetModuleFileName(NULL, buf, MAX_MODULE_NAME32 + 1); diff --git a/core/foundation/inc/ThreadLocalStorage.h b/core/foundation/inc/ThreadLocalStorage.h index 5e690567e7d9d..4b7e05606bd03 100644 --- a/core/foundation/inc/ThreadLocalStorage.h +++ b/core/foundation/inc/ThreadLocalStorage.h @@ -80,6 +80,9 @@ #if defined(R__WIN32) # define R__HAS_DECLSPEC_THREAD #endif +#if defined(R__FBSD) +# define R__HAS_PTHREAD +#endif #ifdef __cplusplus diff --git a/core/foundation/src/FoundationUtils.cxx b/core/foundation/src/FoundationUtils.cxx index 40e359644d786..b779072a7fb27 100644 --- a/core/foundation/src/FoundationUtils.cxx +++ b/core/foundation/src/FoundationUtils.cxx @@ -25,6 +25,7 @@ #include #include + #ifdef _WIN32 #include #include @@ -32,6 +33,15 @@ #include #endif // _WIN32 +#ifdef __FreeBSD__ +#include +#include +#include +#include +#include +#include +#endif // __FreeBSD__ + namespace ROOT { namespace FoundationUtils { std::string GetCurrentDir() @@ -102,17 +112,31 @@ const std::string& GetFallbackRootSys() { static std::string fallback; if (!fallback.empty()) return fallback; + + auto parent_path = [](std::string path) { + return path.substr(0, path.find_last_of("/\\")); + }; + #ifdef WIN32 static char lpFilename[_MAX_PATH]; if (::GetModuleFileNameA( NULL, // handle to module to find filename for lpFilename, // pointer to buffer to receive module path sizeof(lpFilename))) { // size of buffer, in characters - auto parent_path = [](std::string path) { - return path.substr(0, path.find_last_of("/\\")); - }; fallback = parent_path(parent_path(lpFilename)); } +#elif defined __FreeBSD__ + procstat* ps = procstat_open_sysctl(); // + kinfo_proc* kp = kinfo_getproc(getpid()); + + char lpFilename[PATH_MAX] = ""; + if (kp!=NULL) { + procstat_getpathname(ps, kp, lpFilename, sizeof(lpFilename)); + fallback = parent_path(parent_path({lpFilename})); + } + + free(kp); + procstat_close(ps); #else // FIXME: We should not hardcode this path. We can use a similar to the // windows technique to get the path to the executable. The easiest way diff --git a/core/metacling/src/CMakeLists.txt b/core/metacling/src/CMakeLists.txt index c631acbd81089..d94d013063cac 100644 --- a/core/metacling/src/CMakeLists.txt +++ b/core/metacling/src/CMakeLists.txt @@ -195,3 +195,8 @@ if(APPLE) elseif(NOT MSVC) target_link_libraries(Cling PUBLIC -Wl,--unresolved-symbols=ignore-in-object-files) endif() + +if (CMAKE_SYSTEM_NAME MATCHES FreeBSD) + target_link_libraries(Cling PUBLIC util procstat) +endif() + diff --git a/core/metacling/src/TCling.cxx b/core/metacling/src/TCling.cxx index 0629d55e79217..cefcd94345afd 100644 --- a/core/metacling/src/TCling.cxx +++ b/core/metacling/src/TCling.cxx @@ -163,7 +163,7 @@ clang/LLVM technology. #include #endif -#ifdef R__LINUX +#if defined(R__LINUX) || defined(R__FBSD) # ifndef _GNU_SOURCE # define _GNU_SOURCE # endif @@ -3264,7 +3264,7 @@ static bool R__UpdateLibFileForLinking(TString &lib) } #endif // R__MACOSX -#ifdef R__LINUX +#if defined (R__LINUX) || defined (R__FBSD) //////////////////////////////////////////////////////////////////////////////// /// Callback for dl_iterate_phdr(), see `man dl_iterate_phdr`. @@ -3279,6 +3279,9 @@ static int callback_for_dl_iterate_phdr(struct dl_phdr_info *info, size_t size, if (!sKnownLoadedLibBaseAddrs.count(info->dlpi_addr)) { // Skip \0, "", and kernel pseudo-libs linux-vdso.so.1 or linux-gate.so.1 if (info->dlpi_name && info->dlpi_name[0] +#if defined(R__FBSD) + && strstr(info->dlpi_name, "[vdso]") +#endif && strncmp(info->dlpi_name, "linux-vdso.so", 13) && strncmp(info->dlpi_name, "linux-vdso32.so", 15) && strncmp(info->dlpi_name, "linux-vdso64.so", 15) @@ -3290,7 +3293,7 @@ static int callback_for_dl_iterate_phdr(struct dl_phdr_info *info, size_t size, return 0; } -#endif // R__LINUX +#endif // R__LINUX || R__FBSD //////////////////////////////////////////////////////////////////////////////// @@ -3337,7 +3340,7 @@ void TCling::UpdateListOfLoadedSharedLibraries() ++imageIndex; } fPrevLoadedDynLibInfo = (void*)(size_t)imageIndex; -#elif defined(R__LINUX) +#elif defined(R__LINUX) || defined(R__FBSD) // fPrevLoadedDynLibInfo is unused on Linux. (void) fPrevLoadedDynLibInfo; diff --git a/core/metacling/src/rootclingTCling.cxx b/core/metacling/src/rootclingTCling.cxx index e168f25f3592f..5f60418b880f5 100644 --- a/core/metacling/src/rootclingTCling.cxx +++ b/core/metacling/src/rootclingTCling.cxx @@ -20,6 +20,11 @@ #undef R__DLLEXPORT +#ifdef __FreeBSD__ +char* __progname; +char** environ; +#endif + #include "TROOT.h" #include "TCling.h" diff --git a/core/rootcling_stage1/CMakeLists.txt b/core/rootcling_stage1/CMakeLists.txt index 75f2415e5d301..a934718bf0087 100644 --- a/core/rootcling_stage1/CMakeLists.txt +++ b/core/rootcling_stage1/CMakeLists.txt @@ -35,6 +35,9 @@ target_include_directories(rootcling_stage1 PRIVATE ${CMAKE_SOURCE_DIR}/core/dictgen/res # for rootcling_impl.h ${CMAKE_BINARY_DIR}/ginclude # for RConfigure.h ) +if (CMAKE_SYSTEM_NAME MATCHES FreeBSD) + target_link_libraries(rootcling_stage1 util procstat) +endif() set_target_properties(rootcling_stage1 PROPERTIES RUNTIME_OUTPUT_DIRECTORY src) add_dependencies(rootcling_stage1 ClingUtils) diff --git a/core/unix/CMakeLists.txt b/core/unix/CMakeLists.txt index 32ef6ab59fa8d..f1bfed48174af 100644 --- a/core/unix/CMakeLists.txt +++ b/core/unix/CMakeLists.txt @@ -16,4 +16,8 @@ set_property(TARGET Core APPEND PROPERTY DICT_HEADERS TUnixSystem.h) target_sources(Core PRIVATE src/TUnixSystem.cxx) target_include_directories(Core PRIVATE inc ../clib/res) +if (CMAKE_SYSTEM_NAME MATCHES FreeBSD) + target_link_libraries(Core PRIVATE execinfo util) +endif() + ROOT_INSTALL_HEADERS() diff --git a/core/unix/src/TUnixSystem.cxx b/core/unix/src/TUnixSystem.cxx index ec6435359b90e..cd1a0cc2528ca 100644 --- a/core/unix/src/TUnixSystem.cxx +++ b/core/unix/src/TUnixSystem.cxx @@ -80,6 +80,14 @@ #elif defined(R__FBSD) || defined(R__OBSD) # include # include +# ifdef R__FBSD +# include +# include +# include +# include +# include +# include +# endif #else # include #endif @@ -180,7 +188,7 @@ extern "C" { # endif # define HAVE_DLADDR #endif -#if defined(R__MACOSX) +#if defined(R__MACOSX) || defined(R__FBSD) # define HAVE_BACKTRACE_SYMBOLS_FD # define HAVE_DLADDR #endif @@ -404,7 +412,7 @@ static const char *GetExePath() #if defined(R__MACOSX) exepath = _dyld_get_image_name(0); #elif defined(R__LINUX) || defined(R__SOLARIS) || defined(R__FBSD) - char buf[kMAXPATHLEN]; // exe path name + char buf[kMAXPATHLEN]=""; // exe path name // get the name from the link in /proc #if defined(R__LINUX) @@ -412,7 +420,16 @@ static const char *GetExePath() #elif defined(R__SOLARIS) int ret = readlink("/proc/self/path/a.out", buf, kMAXPATHLEN); #elif defined(R__FBSD) - int ret = readlink("/proc/curproc/file", buf, kMAXPATHLEN); + procstat* ps = procstat_open_sysctl(); + kinfo_proc* kp = kinfo_getproc(getpid()); + + int ret{0}; + if (kp!=NULL) { + procstat_getpathname(ps, kp, buf, sizeof(buf)); + } + free(kp); + procstat_close(ps); + exepath = buf; #endif if (ret > 0 && ret < kMAXPATHLEN) { buf[ret] = 0; diff --git a/etc/Makefile.arch b/etc/Makefile.arch index d2eaeaec62783..2e04959a2ffe1 100644 --- a/etc/Makefile.arch +++ b/etc/Makefile.arch @@ -286,6 +286,15 @@ LDFLAGS = $(OPT) SOFLAGS = -shared -Wl,-x endif +ifeq ($(findstring freebsd,$(ARCH)),freebsd) +# FreeBSD with libc +CXX = c++ +CXXFLAGS = $(OPT2) -W -Wall -fPIC +LD = $(CXX) +LDFLAGS = $(OPT2) +SOFLAGS = -shared -Wl,-x +endif + ifeq ($(ARCH),openbsd) # OpenBSD with libc CXX = g++ diff --git a/interpreter/cling/lib/Interpreter/DynamicLibraryManagerSymbol.cpp b/interpreter/cling/lib/Interpreter/DynamicLibraryManagerSymbol.cpp index dda5897a3cd46..3e7fbd6dc7aab 100644 --- a/interpreter/cling/lib/Interpreter/DynamicLibraryManagerSymbol.cpp +++ b/interpreter/cling/lib/Interpreter/DynamicLibraryManagerSymbol.cpp @@ -37,6 +37,26 @@ #include #include +#if defined (__FreeBSD__) +#include +#include +#include +#include + +// libprocstat pulls in sys/elf.h which seems to clash with llvm/BinaryFormat/ELF.h +// similar collision happens with ZFS. Defining ZFS disables this include. +# ifndef ZFS +# define ZFS +# define defined_ZFS_for_libprocstat +# endif +#include +# ifdef defined_ZFS_for_libprocstat +# undef ZFS +# undef defined_ZFS_for_libprocstat +# endif + +#include +#endif #ifdef LLVM_ON_UNIX #include @@ -1363,6 +1383,17 @@ namespace cling { if (_NSGetExecutablePath(buf, &bufsize) >= 0) return cached_realpath(buf); return cached_realpath(info.dli_fname); +# elif defined (__FreeBSD__) + procstat* ps = procstat_open_sysctl(); + kinfo_proc* kp = kinfo_getproc(getpid()); + + char buf[PATH_MAX] = ""; + if (kp!=NULL) { + procstat_getpathname(ps, kp, buf, sizeof(buf)); + }; + free(kp); + procstat_close(ps); + return cached_realpath(buf); # elif defined(LLVM_ON_UNIX) char buf[PATH_MAX] = { 0 }; // Cross our fingers that /proc/self/exe exists. diff --git a/interpreter/cling/lib/Utils/PlatformPosix.cpp b/interpreter/cling/lib/Utils/PlatformPosix.cpp index a01887d673b38..68da3a67ff9be 100644 --- a/interpreter/cling/lib/Utils/PlatformPosix.cpp +++ b/interpreter/cling/lib/Utils/PlatformPosix.cpp @@ -169,7 +169,7 @@ bool Popen(const std::string& Cmd, llvm::SmallVectorImpl& Buf, bool RdE) { } bool GetSystemLibraryPaths(llvm::SmallVectorImpl& Paths) { -#if defined(__APPLE__) || defined(__CYGWIN__) +#if defined(__APPLE__) || defined(__CYGWIN__) || defined(R__FBSD) Paths.push_back("/usr/local/lib/"); Paths.push_back("/usr/X11R6/lib/"); Paths.push_back("/usr/lib/"); diff --git a/io/io/src/TFile.cxx b/io/io/src/TFile.cxx index 63bab928f2d02..f64e5c15ca92e 100644 --- a/io/io/src/TFile.cxx +++ b/io/io/src/TFile.cxx @@ -85,7 +85,9 @@ The structure of a directory is shown in TDirectoryFile::TDirectoryFile #include #ifndef WIN32 #include +#ifndef R__FBSD #include +#endif #else # define ssize_t int # include @@ -141,6 +143,10 @@ The structure of a directory is shown in TDirectoryFile::TDirectoryFile #include "ROOT/RConcurrentHashColl.hxx" #include +#ifdef R__FBSD +#include +#endif + using std::sqrt; std::atomic TFile::fgBytesRead{0}; @@ -163,6 +169,9 @@ ROOT::Internal::RConcurrentHashColl TFile::fgTsSIHashes; /* On macOS getxattr takes two extra arguments that should be set to 0 */ #define getxattr(path, name, value, size) getxattr(path, name, value, size, 0u, 0) #endif +#ifdef R__FBSD +#define getxattr(path, name, value, size) extattr_get_file(path, EXTATTR_NAMESPACE_USER, name, value, size) +#endif const Int_t kBEGIN = 100; diff --git a/net/auth/CMakeLists.txt b/net/auth/CMakeLists.txt index eee65f3736c42..a98e659ec8649 100644 --- a/net/auth/CMakeLists.txt +++ b/net/auth/CMakeLists.txt @@ -33,3 +33,4 @@ ROOT_STANDARD_LIBRARY_PACKAGE(RootAuth ) target_link_libraries(RootAuth PRIVATE rsa $<$:crypt>) +target_link_libraries(RootAuth PRIVATE rsa $<$:crypt>) diff --git a/net/rpdutils/CMakeLists.txt b/net/rpdutils/CMakeLists.txt index b7c2dd421a3c3..a45c58d5eb52f 100644 --- a/net/rpdutils/CMakeLists.txt +++ b/net/rpdutils/CMakeLists.txt @@ -61,3 +61,8 @@ target_include_directories(SrvAuth PRIVATE ${CMAKE_SOURCE_DIR}/net/auth/inc ${CMAKE_SOURCE_DIR}/rpdutils/res ) + +if (CMAKE_SYSTEM_NAME MATCHES FreeBSD) + target_link_libraries(SrvAuth PRIVATE crypt) +endif() + diff --git a/rootx/CMakeLists.txt b/rootx/CMakeLists.txt index 2427805aa5f3a..242fcd2dc8836 100644 --- a/rootx/CMakeLists.txt +++ b/rootx/CMakeLists.txt @@ -25,6 +25,11 @@ if(x11) ${X11_Xpm_LIB} ${X11_LIBRARIES} ) + +if (CMAKE_SYSTEM_NAME MATCHES FreeBSD) + target_link_libraries(root PRIVATE util procstat) +endif() + elseif(cocoa) if (cxxmodules) # FIXME: Disable modules for ObjC/ObjC++. It has problems when compiling diff --git a/rootx/src/rootx.cxx b/rootx/src/rootx.cxx index 4403568ff2a19..53106fa5eef70 100644 --- a/rootx/src/rootx.cxx +++ b/rootx/src/rootx.cxx @@ -37,6 +37,14 @@ #include #endif +#ifdef R__FBSD +#include +#include +#include +#include +#include +#endif // R__FBSD + #ifdef __sun # ifndef _REENTRANT # if __SUNPRO_CC > 0x420 @@ -120,6 +128,19 @@ static const char *GetExePath() buf[ret] = 0; exepath = buf; } +#endif +#if defined(R__FBSD) + procstat* ps = procstat_open_sysctl(); // + kinfo_proc* kp = kinfo_getproc(getpid()); + + if (kp!=NULL) { + char path_str[PATH_MAX] = ""; + procstat_getpathname(ps, kp, path_str, sizeof(path_str)); + exepath = path_str; + } + + free(kp); + procstat_close(ps); #endif } return exepath.c_str();