Skip to content
This repository has been archived by the owner on Jan 13, 2024. It is now read-only.

Static link libstdc++ #555

Closed
aslafy-z opened this issue Oct 17, 2018 · 10 comments
Closed

Static link libstdc++ #555

aslafy-z opened this issue Oct 17, 2018 · 10 comments

Comments

@aslafy-z
Copy link

I'd like to ask pkg to statically link libstdc++ into the binary file. I currently need to add libstdc++ into my alpine container before running my binary file and I would like not having to.

FROM alpine:3.8
RUN apk add --no-cache libstdc++
COPY ./bin /bin
ENTRYPOINT ["/bin"]

Any thoughts?
Is this possible?

@danawoodman
Copy link

I'd love to know this too!

@nickgrealy
Copy link

I presume this is the reason I'm getting the following error, when trying to run my binary in a scratch dockerfile:

Script
pkg --debug --targets node10-linux-x64 --output runme index.js

Dockerfile

FROM scratch
COPY runme /
CMD ["/runme"]

Error

standard_init_linux.go:211: exec user process caused "no such file or directory"

@nickgrealy
Copy link

@nickgrealy
Copy link

nickgrealy commented Oct 16, 2019

@igorklopov - first of all, thanks for an awesome tool!

Just reading your comments here...

Right. Try running args.push('--fully-static') here https://github.com/zeit/pkg-fetch/blob/master/lib/build.js#L72 and then passing -b option to your pkg call.

Is there any chance we can have this added to the pkg library (maybe as a CLI option)?

(I'd do it myself, but not sure if there's a reason it hasn't already been added.)

@hsablonniere
Copy link

Hey wonderful team of pkg 😉 thanks for this awesome tool!

We're also interested in this issue at Clever Cloud for our CLI and we're available to test any alpha/beta if needed.

@github-actions
Copy link

This issue is stale because it has been open 90 days with no activity. Remove the stale label or comment or this will be closed in 5 days. To ignore this issue entirely you can add the no-stale label

@github-actions github-actions bot added the Stale label Apr 10, 2021
@robertsLando
Copy link
Contributor

cc @jesec ?

@jesec
Copy link
Contributor

jesec commented Apr 11, 2021

That would increase the binary size unnecessarily for majority of users, as it is simply improbable for a functional system to NOT have the standard C++ library. Additionally, static linking has certain security implications, and some distributions (such as EL) simply don’t provide static libraries (*.a).

Instead, make it Alpine only.

@github-actions github-actions bot removed the Stale label Apr 12, 2021
@robertsLando
Copy link
Contributor

Instead, make it Alpine only.

Yeah I think they means to add this just for alpine binaries, btw I think that add an apk install command isn't that hard to do... Maybe we could add some docs about this

jesec added a commit to jesec/pkg-fetch that referenced this issue Apr 12, 2021
jesec added a commit to jesec/pkg-fetch that referenced this issue Apr 12, 2021
jesec added a commit to jesec/pkg-fetch that referenced this issue Apr 13, 2021
jesec added a commit to jesec/pkg-fetch that referenced this issue Apr 13, 2021
jesec added a commit to vercel/pkg-fetch that referenced this issue Apr 15, 2021
jesec added a commit to vercel/pkg-fetch that referenced this issue Apr 15, 2021
@jesec
Copy link
Contributor

jesec commented May 14, 2021

This issue has been resolved. Please let me know if it is still relevant.

@jesec jesec closed this as completed May 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants