Skip to content

Commit

Permalink
Merge branch musl into master
Browse files Browse the repository at this point in the history
  • Loading branch information
amadio committed Feb 17, 2023
2 parents 751bf28 + cfd2b1d commit 59fb5be
Show file tree
Hide file tree
Showing 20 changed files with 212 additions and 54 deletions.
85 changes: 85 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,91 @@ jobs:
# ./common/test-runner ./XrdClTests/libXrdClTests.so 'All Tests/FileSystemTest/'
# ./common/test-runner ./XrdClTests/libXrdClTests.so 'All Tests/LocalFileHandlerTest/'
cmake-alpine-musl:

runs-on: ubuntu-latest
container: alpine

steps:
- name: Install external dependencies
shell: sh
run: |
apk add \
bash \
cmake \
cppunit-dev \
curl-dev \
fuse-dev \
fuse3-dev \
g++ \
git \
json-c-dev \
krb5-dev \
libxml2-dev \
linux-headers \
make \
openssl-dev \
py3-pip \
python3-dev \
readline-dev \
tinyxml-dev \
util-linux-dev \
zlib-dev
- name: Clone repository
uses: actions/checkout@v2

- name: Build with cmake
run: |
cd ..
# need to fix ownership not to confuse git
chown -R -v "$( id -u; ):$( id -g; )" xrootd
cmake \
-DCMAKE_CXX_STANDARD=17 \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_INSTALL_LIBDIR=lib \
-DPYTHON_EXECUTABLE=$(command -v python3) \
-DFORCE_ENABLED=ON \
-DENABLE_HTTP=OFF \
-DENABLE_TESTS=ON \
-DENABLE_VOMS=OFF \
-DENABLE_XRDEC=OFF \
-DENABLE_XRDCLHTTP=OFF \
-DENABLE_MACAROONS=OFF \
-DENABLE_SCITOKENS=OFF \
-DPIP_OPTIONS="--verbose" \
-S xrootd \
-B build
cmake build -LH
cmake \
--build build \
--clean-first \
--parallel $(($(nproc) - 1))
cmake --build build --target install
python3 -m pip list
- name: Verify install
run: |
command -v xrootd
command -v xrdcp
- name: Verify Python bindings
run: |
python3 --version --version
python3 -m pip list
python3 -m pip show xrootd
python3 -c 'import XRootD; print(XRootD)'
python3 -c 'import pyxrootd; print(pyxrootd)'
python3 -c 'from XRootD import client; print(client.FileSystem("root://someserver:1094"))'
- name: Run libXrdCl tests
run: |
cd ../build/tests
./common/test-runner ./XrdClTests/libXrdClTests.so 'All Tests/UtilsTest/'
./common/test-runner ./XrdClTests/libXrdClTests.so 'All Tests/SocketTest/'
./common/test-runner ./XrdClTests/libXrdClTests.so 'All Tests/PollerTest/'
cmake-centos7:

runs-on: ubuntu-latest
Expand Down
15 changes: 15 additions & 0 deletions cmake/XRootDOSDefs.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,21 @@ if( ${CMAKE_SYSTEM_NAME} STREQUAL "Linux" )
set( LINUX TRUE )
include( GNUInstallDirs )
set( EXTRA_LIBS rt )

# Check for musl libc with the compiler, since it provides way to detect it
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpmachine
OUTPUT_VARIABLE TARGET_TRIPLE ERROR_VARIABLE TARGET_ERROR)

if (NOT TARGET_ERROR)
if ("${TARGET_TRIPLE}" MATCHES "musl")
message(STATUS "Detected musl libc")
add_definitions(-DMUSL=1)
endif()
else()
message(WARNING "Could not detect system information!")
endif()

unset(TARGET_ERROR)
endif()

#-------------------------------------------------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions src/Xrd/XrdConfig.hh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
#include "Xrd/XrdProtLoad.hh"
#include "Xrd/XrdProtocol.hh"

#include <sys/types.h>

class XrdSysError;
class XrdTcpMonInfo;
class XrdNetSecurity;
Expand Down
2 changes: 1 addition & 1 deletion src/Xrd/XrdPoll.hh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
/* specific prior written permission of the institution or contributor. */
/******************************************************************************/

#include <sys/poll.h>
#include <poll.h>
#include "XrdSys/XrdSysPthread.hh"

#define XRD_NUMPOLLERS 3
Expand Down
8 changes: 8 additions & 0 deletions src/XrdAcc/XrdAccGroups.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@
#include "XrdAcc/XrdAccGroups.hh"
#include "XrdAcc/XrdAccPrivs.hh"

#ifdef MUSL
int innetgr(const char *netgroup, const char *host, const char *user,
const char *domain)
{
return 0;
}
#endif

// Additionally, this routine does not support a user in more than
// NGROUPS_MAX groups. This is a standard unix limit defined in limits.h.

Expand Down
1 change: 1 addition & 0 deletions src/XrdCl/XrdClFileStateHandler.hh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include <set>
#include <vector>

#include <sys/time.h>
#include <sys/uio.h>
#include <cstdint>

Expand Down
2 changes: 2 additions & 0 deletions src/XrdCl/XrdClMonitor.hh
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@

#include "XrdCl/XrdClFileSystem.hh"

#include <sys/time.h>

namespace XrdCl
{
class URL;
Expand Down
2 changes: 1 addition & 1 deletion src/XrdNet/XrdNetMsg.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
/******************************************************************************/

#include <cerrno>
#include <sys/poll.h>
#include <poll.h>

#include "XrdNet/XrdNet.hh"
#include "XrdNet/XrdNetMsg.hh"
Expand Down
13 changes: 8 additions & 5 deletions src/XrdNet/XrdNetSecurity.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@
#include <sys/types.h>
#include <Winsock2.h>
#include <io.h>
int innetgr(const char *netgroup, const char *host, const char *user,
const char *domain)
{
return 0;
}
#include "XrdSys/XrdWin32.hh"
#endif

Expand All @@ -53,6 +48,14 @@ int innetgr(const char *netgroup, const char *host, const char *user,
#include "XrdNet/XrdNetUtils.hh"
#include "XrdSys/XrdSysTrace.hh"

#if defined(MUSL) || defined(WIN32)
int innetgr(const char *netgroup, const char *host, const char *user,
const char *domain)
{
return 0;
}
#endif

/******************************************************************************/
/* L o c a l C l a s s e s */
/******************************************************************************/
Expand Down
2 changes: 1 addition & 1 deletion src/XrdOfs/XrdOfsHandle.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

#include <cstdio>
#include <ctime>
#include <sys/errno.h>
#include <errno.h>
#include <sys/types.h>

#include "XrdOfs/XrdOfsHandle.hh"
Expand Down
6 changes: 3 additions & 3 deletions src/XrdOssCsi/XrdOssCsiTagstoreFile.hh
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@
#include <memory>
#include <mutex>

#if defined(__GLIBC__) || defined(__BIONIC__) || defined(__CYGWIN__)
#include <byteswap.h>
#elif defined(__APPLE__)
#if defined(__APPLE__)
// Make sure that byte swap functions are not already defined.
#if !defined(bswap_16)
// Mac OS X / Darwin features
Expand All @@ -49,6 +47,8 @@
#define bswap_32(x) OSSwapInt32(x)
#define bswap_64(x) OSSwapInt64(x)
#endif
#else
#include <byteswap.h>
#endif

class XrdOssCsiTagstoreFile : public XrdOssCsiTagstore
Expand Down
12 changes: 5 additions & 7 deletions src/XrdOuc/XrdOucBackTrace.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#include <vector>
#include <sys/syscall.h>

#ifdef __GNUC__
#ifndef MUSL /* glibc, uclibc, and macOS all have execinfo.h */
#include <execinfo.h>
#include <cxxabi.h>
#endif
Expand Down Expand Up @@ -176,13 +176,11 @@ XrdInfo *CvtRsp(const char *name, int snum)
/* D e m a n g l e */
/******************************************************************************/

#ifndef MUSL
namespace
{
int Demangle(char *cSym, char *buff, int blen)
{
#ifndef __GNUC__
return -1;
#else
int status;
char *plus = index(cSym, '+');
char *brak = (plus ? index(plus, '[') : 0);
Expand All @@ -201,7 +199,6 @@ int Demangle(char *cSym, char *buff, int blen)
status = snprintf(buff, blen, "%s %s+%s\n", brak, realname, plus+1);
free(realname);
return status;
#endif
}
}

Expand All @@ -221,6 +218,7 @@ int DumpDepth()
return (depth <= maxDepth ? depth : maxDepth);
}
}
#endif

/******************************************************************************/
/* D u m p S t a c k */
Expand All @@ -230,8 +228,8 @@ namespace
{
void DumpStack(char *bP, int bL, TidType tid)
{
#ifndef __GNUC__
snprintf(bP, bL, "TBT " TidFmt " No stack information available, not gnuc.", tid);
#ifdef MUSL
snprintf(bP, bL, "TBT " TidFmt " No stack information available with musl libc.", tid);
return;
#else
static int btDepth = DumpDepth(); // One time MT-safe call
Expand Down
80 changes: 57 additions & 23 deletions src/XrdPosix/XrdPosix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,58 @@

extern XrdPosixLinkage Xunix;

/******************************************************************************/
/* U t i l i t y F u n c t i o n s */
/******************************************************************************/

#ifdef MUSL
#include <stdio_ext.h>
#endif

static inline void fseterr(FILE *fp)
{
/* Most systems provide FILE as a struct and the necessary bitmask in
<stdio.h>, because they need it for implementing getc() and putc() as
fast macros. This function is based on gnulib's fseterr.c */
#if defined _IO_ERR_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1
/* GNU libc, BeOS, Haiku, Linux libc5 */
fp->_flags |= _IO_ERR_SEEN;
#elif defined __sferror || defined __APPLE__ || defined __DragonFly__ || defined __ANDROID__
/* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
fp->_flags |= __SERR;
#elif defined _IOERR
/* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, UnixWare, mingw, MSVC, NonStop Kernel, OpenVMS */
fp->_flag |= _IOERR;
#elif defined __UCLIBC__ /* uClibc */
fp->__modeflags |= __FLAG_ERROR;
#elif defined MUSL /* musl libc */
__fseterr(fp);
#else
#error "Unsupported platform! Please report it as a bug."
#endif
}

static inline void fseteof(FILE *fp)
{
/* Most systems provide FILE as a struct and the necessary bitmask in
<stdio.h>, because they need it for implementing getc() and putc() as
fast macros. */
#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1
/* GNU libc, BeOS, Haiku, Linux libc5 */
fp->_flags |= _IO_EOF_SEEN;
#elif defined __sferror || defined __APPLE__ || defined __DragonFly__ || defined __ANDROID__
/* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
fp->_flags |= __SEOF;
#elif defined _IOEOF
/* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, UnixWare, mingw, MSVC, NonStop Kernel, OpenVMS */
fp->_flag |= _IOEOF;
#elif defined __UCLIBC__ /* uClibc */
fp->__modeflags |= __FLAG_EOF;
#else
(void) fseek(fp, 0L, SEEK_END);
#endif
}

/******************************************************************************/
/* X r d P o s i x _ A c c e s s */
/******************************************************************************/
Expand Down Expand Up @@ -308,19 +360,9 @@ size_t XrdPosix_Fread(void *ptr, size_t size, size_t nitems, FILE *stream)

// Get the right return code. Note that we cannot emulate the flags in sunx86
//
if (bytes > 0 && size) rc = bytes/size;
#ifndef SUNX86
#if defined(__linux__) || defined(__GNU__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__))
else if (bytes < 0) stream->_flags |= _IO_ERR_SEEN;
else stream->_flags |= _IO_EOF_SEEN;
#elif defined(__APPLE__) || defined(__FreeBSD__)
else if (bytes < 0) stream->_flags |= __SEOF;
else stream->_flags |= __SERR;
#else
else if (bytes < 0) stream->_flag |= _IOERR;
else stream->_flag |= _IOEOF;
#endif
#endif
if (bytes > 0 && size) rc = bytes/size;
else if (bytes < 0) fseterr(stream);
else fseteof(stream);

return rc;
}
Expand Down Expand Up @@ -477,18 +519,10 @@ size_t XrdPosix_Fwrite(const void *ptr, size_t size, size_t nitems, FILE *stream

bytes = Xroot.Write(fd, ptr, size*nitems);

// Get the right return code. Note that we cannot emulate the flags in sunx86
// Get the right return code.
//
if (bytes > 0 && size) rc = bytes/size;
#ifndef SUNX86
#if defined(__linux__) || defined(__GNU__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__))
else stream->_flags |= _IO_ERR_SEEN;
#elif defined(__APPLE__) || defined(__FreeBSD__)
else stream->_flags |= __SERR;
#else
else stream->_flag |= _IOERR;
#endif
#endif
else fseterr(stream);

return rc;
}
Expand Down
1 change: 1 addition & 0 deletions src/XrdPosix/XrdPosixFile.hh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <sys/time.h>
#include <sys/param.h>
#include <sys/resource.h>
#include <sys/types.h>
#include <sys/uio.h>

#include "XrdCl/XrdClFileSystem.hh"
Expand Down
1 change: 1 addition & 0 deletions src/XrdPosix/XrdPosixLinkage.hh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include <unistd.h>

#include "XrdPosix/XrdPosixOsDep.hh"
#include "XrdPosix/XrdPosixXrootd.hh"
#include "XrdSys/XrdSysPlatform.hh"

/******************************************************************************/
Expand Down
Loading

0 comments on commit 59fb5be

Please sign in to comment.