charliecloud icon indicating copy to clipboard operation
charliecloud copied to clipboard

replace argp with something more portable

Open reidpr opened this issue 4 years ago • 1 comments

We use GNU argp to parse command line arguments. This is a GNU extension and only present in glibc. Building with another libc means that argp must be supplied externally (see PR #1258), but this appears to not be well supported. While there is an Alpine package, it depends on an apparently-unmaintained extraction of the argp code from glibc dated 2004.

An alternative is getopt_long(3), which is also a GNU extension but does appear to be supported by musl.

There is a tool called Gengetopt that provides a DSL compiled to getopt_long(3) calls and supporting code.

One thing we currently rely on from argp is that in ch-run --set-env FOO -- ..., it knows FOO is the image name, not the argument to --set-env. getopt_long(3) uses a greedy algorithm and thus AFAICT will get this wrong.

reidpr avatar Dec 21 '21 21:12 reidpr

The argp-standalone maintained at: https://github.com/ericonr/argp-standalone is what Gentoo uses and seems to be slightly better maintained than what Alpine is using right now. However, the general argument to switch to something more portable holds.

olifre avatar Dec 21 '21 21:12 olifre