larmel / lacc

A simple, self-hosting C compiler
MIT License
872 stars 64 forks source link

cp: unrecognized option: target-directory #30

Closed bensuperpc closed 3 years ago

bensuperpc commented 3 years ago

I have a problem is trying to install the compiler, I have this error:

Step 5/18 : RUN make install
 ---> Running in 20e0b2a6a1ef
mkdir -p bin/include
cp include/stdlib/alloca.h include/stdlib/float.h include/stdlib/stdalign.h include/stdlib/stdarg.h include/stdlib/stdbool.h include/stdlib/stddef.h --target-directory=bin/include
cp: unrecognized option: target-directory=bin/include
BusyBox v1.32.1 () multi-call binary.

Usage: cp [OPTIONS] SOURCE... DEST

Copy SOURCE(s) to DEST

        -a      Same as -dpR
        -R,-r   Recurse
        -d,-P   Preserve symlinks (default if -R)
        -L      Follow all symlinks
        -H      Follow symlinks on command line
        -p      Preserve file attributes if possible
        -f      Overwrite
        -i      Prompt before overwrite
        -l,-s   Create (sym)links
        -T      Treat DEST as a normal file
        -u      Copy only newer files
make: *** [Makefile:93: bin/include] Error 1
The command '/bin/sh -c make install' returned a non-zero code: 2

I am under alpine linux, in docker, on linux/amd64. If you want to see project : https://github.com/bensuperpc/docker-lacc

bensuperpc commented 3 years ago

Update: i install coreutils package in alpine linux and it working now.

rofl0r commented 3 years ago

could you please leave this open, you're not the only one using non-gnu coreutils.

larmel commented 3 years ago

This should be fixed now. I made some improvements to better support musl, and also started testing myself on alpine using docker. Thanks for reporting!

rofl0r commented 3 years ago

unfortunately your ldd approach on the host doesn't quite work - see my commit comment - and is additionally incompatible with cross-compilation. my article here https://sabotage-linux.neocities.org/blog/5/ describes various cross-compile safe approaches, imo the best here would be to run $(CC) -dumpmachine and parse the resulting string.

$ gcc -dumpmachine
x86_64-unknown-linux-musl
$ musl-cross-make-6.5.0/x86_64-linux-musl/bin/x86_64-linux-musl-gcc -dumpmachine
x86_64-linux-musl
larmel commented 3 years ago

Thanks for the instructive feedback @rofl0r. It seems to me a configure script is unavoidable, so I have added a simple version of that. Hopefully it should be more correct wrt cross compilation, and easier to properly support more targets and options in the future.