-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Description
Enhancement
I was trying to implement miniob on alpine linux for further development. However, the MUSL LIBC do not support all the features that common GNU LIBC supports like address sanitizer. I did not find a solution and turn the option off sadly. But I did successfully compile the project on alpine linux after some fixes.
- Function get_process_name use
basename()in its implementation while not including header filelibgen.h. I try to fix this problem using following implementation. It needsfilesysteminstead, but more cpp way I thought.
string get_process_name(const char *prog_name)
{
return std::filesystem::path(prog_name).filename().c_str();
}- Systems not using
GNU LIBCmay not have macros likePTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NPandPTHREAD_ERRORCHECK_MUTEX_INITIALIZER. For example,MUSL LIBChas pthread api while not implementing the macros mentioned before. Here is the explanation. I do not know much about mutexattr right now, so I try to fix problem on source code using code list below. Bad as not detecting if usingMUSL LIBC, but fixed the problem.
#if defined(LINUX)
#if not defined(__USE_GNU__)
static pthread_mutexattr_t mtxattr;
static pthread_mutexattr_t *pmtxattr = nullptr;
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
if (pmtxattr == nullptr) {
pmtxattr = &mtxattr;
pthread_mutexattr_init(pmtxattr);
pthread_mutexattr_settype(pmtxattr, PTHREAD_MUTEX_ERRORCHECK);
pthread_mutex_init(&mutex, pmtxattr);
}
#else
static pthread_mutex_t mutex = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP;
#endif
#elif defined(__MACH__)
static pthread_mutex_t mutex = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER;
#endif-
This line use the wrong header file as it should be just
errno.h. -
MUSL LIBCdo not havelibexecinfo, and need to be installed manually. After installation, theCMakeLists.txtindeps/commonneed to be added a link option tolibexecinfo. -
MUSL LIBChas pthread api, butcmakemay not detect pthread. It requires addingSET(CMAKE_THREAD_LIBS_INIT "-lpthread")to the topCMakeLists.txt. -
Missing header file
stdint.hinring_buffer.h.
After fixing the problems list above, I compiled the project and tested some functions successfully. The first two fixes may not follow your principle of code, so I did not give a PR. I gave an issue so that you can implement the fixes in your style.
Thank you.