Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build fails under alpine Linux (w/musl libc) #90

Closed
rhowe-gds opened this issue Jul 16, 2019 · 4 comments
Closed

Build fails under alpine Linux (w/musl libc) #90

rhowe-gds opened this issue Jul 16, 2019 · 4 comments
Assignees

Comments

@rhowe-gds
Copy link

rhowe-gds commented Jul 16, 2019

Observed when building appmetrics under alpine 3.10.1: RuntimeTools/appmetrics#454 (comment)

../omr-agentcore/src/ibmras/common/port/linux/Thread.cpp: In function 'void ibmras::common::port::stopAllThreads()':
../omr-agentcore/src/ibmras/common/port/linux/Thread.cpp:144:8: error: 'pthread_getname_np' was not declared in this scope
   rc = pthread_getname_np(top, theName, 16);
        ^~~~~~~~~~~~~~~~~~

Introduced by commit 7b11cfe, but pthread_getname_np is not available in musl libc (only setname)

Reproducible by adding this Dockerfile

FROM alpine:3.10.1

RUN ["apk", "add", "--no-cache", "make", "g++"]

ADD . /omr-agentcore

ENV BUILD=xa64

WORKDIR /omr-agentcore

RUN ["make"]

and running docker build .

@robolivable
Copy link

robolivable commented Jul 17, 2019

Quite a coincidence! I've been working on getting this exact issue resolved in the past couple of days. My temporary work around just for getting a POC up is actually going ahead and implementing the pthread_getname_np method in musl. Building these as separate binaries from source, and pointing the binding.gyp file to the includes/libs does the trick for now...

I wonder about the need for this method in the first place... maybe there's an alternative for the commit that introduced its use?

@rhowe-gds
Copy link
Author

I think it's only used for monitoring the JVM and therefore isn't needed at all for appmetrics. I can't see how else you could identify a particular thread although maybe the way to do it is to keep a reference to all the threads we create and use that list when stopping them?

@frostmar
Copy link

frostmar commented Sep 13, 2019

I've run into this problem when trying to use the appmetrics nodejs package in an Alpine Linux docker image.
npm install appmetrics fails with the C compiler error above.

FWIW, it seems like msul is considering supporting pthread_getname_np
A search turns up this on the msul developer mailing list archive from July 2019:
https://www.openwall.com/lists/musl/2019/07/17/3

On Wed, Jul 17, 2019 at 12:20:09AM -0400, Robert Oliveira wrote:
I'm simply curious about the absence of a pthread getter method
(phtread_getname_np) in musl, since it seems the setter method
(pthread_setname_np) has been around for a while. This only came up because
of a reference to this method in a NodeJS library that uses some cpp
bindings (when using an Alpine image for running Node).

Here's a relevant Github link regarding the matter, for what it's worth:
#90

Thanks in advance for your time.

It's come up before, and there were reasons for not doing it, but not
terribly compelling ones. I promised to look at it again this release
cycle and I suspect that'll end with it getting added.
Rich

@mattcolegate
Copy link
Member

OK everyone, been a while coming but I've sorted out our problems with Alpine and you're good to go on this.
Omr agentcore 4.0.5, Appmetrics 5.0.5, also available on npm.
I tested using this Dockerfile:

FROM node:alpine

RUN ["apk", "add", "--no-cache", "make", "g++", "python", "git"]

RUN ["npm", "install", "appmetrics"]

WORKDIR node_modules/appmetrics

RUN ["npm", "install"]

RUN ["npm", "test"]

Open new issues if you have any :-)

Fazendaaa added a commit to Estatcamp/musl that referenced this issue Mar 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants