musl-libc | Musl-libc copy git
kandi X-RAY | musl-libc Summary
kandi X-RAY | musl-libc Summary
musl, pronounced like the word "mussel", is an MIT-licensed implementation of the standard C library targetting the Linux syscall API, suitable for use in a wide range of deployment environments. musl offers efficient static and dynamic linking support, lightweight code and low runtime overhead, strong fail-safe guarantees under correct usage, and correctness in the sense of standards conformance and safety. musl is built on the principle that these goals are best achieved through simple code that is easy to understand and maintain. The 1.0 release series for musl features coverage for all interfaces defined in ISO C99 and POSIX 2008 base, along with a number of non-standardized interfaces for compatibility with Linux, BSD, and glibc functionality.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of musl-libc
musl-libc Key Features
musl-libc Examples and Code Snippets
Community Discussions
Trending Discussions on musl-libc
QUESTION
What is the difference between alpine docker image and busybox docker image ?
When I check their dockfiles, alpine is like this (for Alpine v3.12 - 3.12.7)
...ANSWER
Answered 2021-May-18 at 14:22The key difference between these is that older versions of the busybox
image statically linked busybox against glibc (current versions dynamically link busybox against glibc due to use of libnss even in static configuration), whereas the alpine
image dynamically links against musl libc.
Going into the weighting factors used to choose between these in detail would be off-topic here (software recommendation requests), but some key points:
Comparing glibc against musl libc, a few salient points (though there are certainly many other factors as well):
- glibc is built for performance and portability over size (often adding special-case performance optimizations that take a large amount of code).
- musl libc is built for correctness and size over performance (it's willing to be somewhat slower to have a smaller code size and to run in less RAM); and it's much more aggressive about having correct error reporting (instead of just exiting immediately) in the face of resource exhaustion.
- glibc is more widely used, so bugs that manifest against its implementation tend to be caught more quickly. Often, when one is the first person to build a given piece of software against musl, one will encounter bugs (typically in that software, not in musl) or places where the maintainer explicitly chose to use GNU extensions instead of sticking to the libc standard.
- glibc is licensed under LGPL terms; only software under GPL-compatible terms can be statically linked against it; whereas musl is under a MIT license, and usable with fewer restrictions.
Comparing the advantages of a static build against a dynamic build:
- If your system image will only have a single binary executable (written in C or otherwise using a libc), a static build is always better, as it discards any parts of your libraries that aren't actually used by that one executable.
- If your system image is intended to have more binaries added that are written in C, using dynamic linking will keep the overall size down, since it allows those binaries to use the libc that's already there.
- If your system image is intended to have more binaries added in a language that doesn't use libc (this can be the case for Go and Rust, f/e), then you don't benefit from dynamic linking; you don't need the unused parts of libc there because you won't be using them anyhow.
Honestly, these two images don't between themselves cover the whole matrix space of possibilities; there are situations where neither of them is optimal. There would be value to having an image with only busybox that statically links against musl libc (if everything you're going to add is in a non-C language), or an image with busybox that dynamically links against glibc (if you're going to add more binaries that need libc and aren't compatible with musl).
QUESTION
I was trying to use crosstool-ng and get it work to build a cross compiler to target a gnu-based linux distros, since alpine comes with musl-libc I guess the cross tool couldn't directly use the type declarations used in gnu's.
More precisely, at the time of installation of the linux headers when building the toolchain, the /usr/include/linux/types.h
does not contain some type declarations which errors for:
ANSWER
Answered 2021-Mar-13 at 15:57After a lot of hit and trials, I was able to successfully build the toolchain.
The musl-libc is smart, it defines those types itself. So the rpc headers https://code.woboq.org/userspace/glibc/sunrpc/rpc/types.h.html#77 here were conflicting with the types __u_char
that GNU defines but does not define u_char
and more.
We can solve this by passing -D__daddr_t_defined -D__u_char_defined
macros to the c flags on build.
QUESTION
I am trying to compile various programs such as MariaDB with a musl toolchain. That is, I don't want any dependencies on glibc or GNU's linker after compilation has finished.
Thus far, I have been using musl's GCC wrapper, musl-gcc
to compile things. But, with larger programs like MariaDB I struggle to get all the necessary libraries and headers and symlinking or adding environment variables for the compilation doesn't really help.
I see mention of building a cross-compiler targeting musl libc with additional documentation and code at this GitHub repo. From the documentation on the cross-compiler:
This gives you a full, relocatable musl-targeting toolchain, with C++ support and its own library paths you can install third-party libraries into.
It sounds like this could help me, but I am not sure how this is very different from musl's GCC wrapper, which as I understand, just alters where GCC looks for libraries and headers etc.
Ultimately, I am unsure how different this cross-compiler really is from the GCC wrapper and if it would be useful in my case. Why would I need my own library paths to install third-party libraries into when I can just symlink to existing libraries and use the GCC wrapper? Is the cross-compiler the way I should be compiling things, especially bigger code bases?
...ANSWER
Answered 2020-Oct-06 at 19:03All the wrapper does is remove the default library and include paths and add replacement ones. Otherwise, it relies on the compiler's view of the ABI being sufficiently matched that a GCC that thinks it's targeting glibc (*-linux-gnu
) works with a musl (*-linux-musl
) target.
A full GCC toolchain has a number of "target libraries" - libraries that are linked into the output program to provide some functionality the compiler offers. This includes libgcc
(software multiply or divide, software floating point, etc. according to whether the target arch needs these things, and unwinding support for exception handling), libstd++
(the C++ standard library), and a number of other things like libgomp
(GNU OpenMP runtime implementation for use with #pragma OMP ...
). In theory all of these possibly depend on the specific target ABI, including the libc, and potentially link to symbols from libc. In practice, for the most part libgcc
doesn't, and is "safely" reusable with a different libc as long as the basic type definitions and a few other ABI things match.
For the other libraries with more complex dependencies on libc, it's generally not expected that a build against one libc would work with a different one. musl libc provides some degree of ABI-compat for using glibc-linked libraries, so there's some hope that they'd work anyway, but you'd need to copy them to the new library path. However, GCC's C++ standard library headers also seem to have some heavy dependency on the (libc) system headers for the target, and when setup for glibc do not seem to work with musl. There is probably some way to make this work (i.e. to add C++ support to the wrapper), but it's an open problem exactly how to do it.
Even if this could be made to work, though, the deeper you go, the more reasons you're likely to find that you'd rather just have a proper cross-compiler toolchain that knows it's targeting musl. And nowadays these are easy enough to build. But if you find you're needing additonal third party libraries too, and don't want to build them yourself, it probably makes more sense to just use a Docker image (or other container) with a distro that provides library binaries for you.
QUESTION
This is from musl's source code:
...ANSWER
Answered 2020-Sep-20 at 20:05The code in lines 7 - 14 loads the parameters to the syscall in parameter order. Since RDI is loaded at line 8, its value is saved in R11 so that it can be written to parameter 8 (on the stack) at line 14.
In hand-written assembly code, it can be easier to understand and maintain by keeping things organized like this, which outweighs the cost of an extra move instruction.
QUESTION
I have a few cross-compilers on my linux desktop. Some use glibc and some use uclibc (and in future there could be other libc
s too).
Currently, I can go into their sysroot directories and search for libc.so
and try to find which file name it points to (for eg. libc.so
-> libuClibc-1.0.12.so
) and I fetch their names. But this won't last long if naming changes or if cross-compiler itself changes.
Is there a better/reliable programmatic way of detecting the name and version of the libc
being used by a target cross compiler? Or are there any introspection tools available to get details about the target ceros
Note: There are a few similar questions here which normally point to #include
file or similar. That works fine if the generated code can also run on the host. But not suitable for cross-compile environments.
So has anyone been able to detect much more reliably?
EDIT: On the off chance someone comes here looking for detecting musl libc specifically, I've answered another question on SO that is related to this question.
...ANSWER
Answered 2018-May-22 at 15:23To detect the libc name and version at compile time, you can check for preprocessor macros. The following script is just a proof of concept:
QUESTION
I am using musl: https://www.musl-libc.org
If i browse the repository i can see that there are a bunch of crypt related source files (including crypt_sha256.c).
The problem is that there are no header files for them. How am i supposed to use them?
These are the symbols from the lib on my system:
I could also not find any code samples from google how to use the SHA-256 features of musl.
Thanks!
...ANSWER
Answered 2020-Jan-24 at 10:58That's not generic SHA-256 message digest algorithm but a specific algorithm used by the crypt
(3) password hashing function. See the documentation for that function on how it is used.
QUESTION
ANSWER
Answered 2019-Oct-05 at 15:05The whole point of the musl-gcc
wrapper script is to invoke gcc
with the include and library paths adjusted to isolate it from the host include and library ecosystem (which are assumed to be glibc-based). That includes the kernel headers for your host system. If you want to use any libraries (including "header-only libraries" like the kernel headers) with musl-gcc
, you need to build a version against musl instead of glibc and install it in the musl include/library path.
For kernel headers, they don't actually depend on the libc or have any library files; it's just the headers. So you can probably get by with copying (or symlinking) the linux
, asm
, and asm-generic
directories from /usr/include
to the musl include dir. Alternatively you can install them from kernel sources.
If you find you need any significant amount of third-party library stuff, though, it makes more sense to just drop musl-gcc
and use a real cross-compiler. You can get prebuilt binary ones if you're willing to trust them from musl.cc, or build your own (takes about 15 minutes on a typical system nowadays) with musl-cross-make. This will give you kernel headers automatically, as well as a full set of GCC target libraries that let you build C++ software, OpenMP-using software, etc.
QUESTION
I need to compile a C program against musl-libc to make it run on an embedded device. However, I'm failing to compile the program. The source depends on a couple libraries which I pass to the linker like so:
/usr/local/musl/bin/musl-gcc app.c -o app -I../lib -lzlog -lfilter
This is the output I get:
...ANSWER
Answered 2019-Mar-19 at 17:02The include paths in your question are all glibc files, so it looks like the library you're trying to link to was built with glibc. This can sometimes be made to work, but there are limitations. In your case, it was built with the glibc version of _FORTIFY_SOURCE
, which uses symbols from glibc that are not presently available in musl (the _FORTIFY_SOURCE
implementation typically used on musl works differently). Making this work has been on the long-term agenda for a long time, but not a priority; if you can, it's much better to rebuild the library against musl.
QUESTION
I am using yocto project to build linux kernel for my board. I used yocto project version 2.5 SUMO branch and 19.0 poky version. I am going to use MUSL-LibC and this is dependent to Linux 2.6 or later versions as it's shown here : https://www.musl-libc.org/faq.html
I want to know how can I find out which linux kernel version I'm using now ?
...ANSWER
Answered 2019-May-25 at 16:12In your BSP layer you'll find the following parameter:
QUESTION
A bit background.
My goal is to create a super slim docker image with JRE on ARM64. Here are possible areas where I can affect on the final image size.
- Using JAVA 9 and up allows me to leverage new java modules capability.
- Using Alpine for ARM64 provides a super slim base image.
What I have done so far: There is OpenJDK 9 and up releases for ARM64, using modules capability I got JRE size around 30M, that's a great achievement.
Now I'm working on moving to the Alpine base image, it requires to have an OpenJDK be compiled with musl-libc. I managed to recompile the lasted OpenJDK with glibc, my question is how it's complicated to compile the OpenJDK 9 with musl libc, my understanding says, the glibc and musl expose the same interface, basically, the OpenJDK should be compatible with musl-libc.
Any directions to hit this challenge will be appreciated.
...ANSWER
Answered 2019-May-20 at 06:27Just in (May/19) - openjdk9
(experimental) for AArch64 is now available from Alpine repositories!
Package details: https://pkgs.alpinelinux.org/package/edge/testing/aarch64/openjdk9
Grab it using:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install musl-libc
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page