aklomp / base64

Fast Base64 stream encoder/decoder in C99, with SIMD acceleration
BSD 2-Clause "Simplified" License
865 stars 162 forks source link

Build fails on macOS: `make: objcopy: No such file or directory` #140

Open snej opened 5 months ago

snej commented 5 months ago

Cloned the repo and ran make:

cc -std=c99 -O3 -Wall -Wextra -pedantic -DBASE64_STATIC_DEFINE -o bin/base64.o -c bin/base64.c
bin/base64.c:544:10: warning: missing field 'has_arg' initializer [-Wmissing-field-initializers]
                { NULL }
                       ^
1 warning generated.
cp -f lib/exports.txt lib/exports.build.txt
cc -std=c99 -O3 -Wall -Wextra -pedantic -DBASE64_STATIC_DEFINE -Ilib  -o lib/arch/avx512/codec.o -c lib/arch/avx512/codec.c
cc -std=c99 -O3 -Wall -Wextra -pedantic -DBASE64_STATIC_DEFINE -Ilib  -o lib/arch/avx2/codec.o -c lib/arch/avx2/codec.c
cc -std=c99 -O3 -Wall -Wextra -pedantic -DBASE64_STATIC_DEFINE -Ilib -o lib/arch/generic/codec.o -c lib/arch/generic/codec.c
cc -std=c99 -O3 -Wall -Wextra -pedantic -DBASE64_STATIC_DEFINE -Ilib  -o lib/arch/neon32/codec.o -c lib/arch/neon32/codec.c
cc -std=c99 -O3 -Wall -Wextra -pedantic -DBASE64_STATIC_DEFINE -Ilib  -o lib/arch/neon64/codec.o -c lib/arch/neon64/codec.c
cc -std=c99 -O3 -Wall -Wextra -pedantic -DBASE64_STATIC_DEFINE -Ilib  -o lib/arch/ssse3/codec.o -c lib/arch/ssse3/codec.c
cc -std=c99 -O3 -Wall -Wextra -pedantic -DBASE64_STATIC_DEFINE -Ilib  -o lib/arch/sse41/codec.o -c lib/arch/sse41/codec.c
cc -std=c99 -O3 -Wall -Wextra -pedantic -DBASE64_STATIC_DEFINE -Ilib  -o lib/arch/sse42/codec.o -c lib/arch/sse42/codec.c
cc -std=c99 -O3 -Wall -Wextra -pedantic -DBASE64_STATIC_DEFINE -Ilib  -o lib/arch/avx/codec.o -c lib/arch/avx/codec.c
cc -std=c99 -O3 -Wall -Wextra -pedantic -DBASE64_STATIC_DEFINE -Ilib -o lib/lib.o -c lib/lib.c
cc -std=c99 -O3 -Wall -Wextra -pedantic -DBASE64_STATIC_DEFINE -Ilib -o lib/codec_choose.o -c lib/codec_choose.c
cc -std=c99 -O3 -Wall -Wextra -pedantic -DBASE64_STATIC_DEFINE -Ilib -o lib/tables/tables.o -c lib/tables/tables.c
ld -r -o lib/libbase64.o lib/arch/avx512/codec.o lib/arch/avx2/codec.o lib/arch/generic/codec.o lib/arch/neon32/codec.o lib/arch/neon64/codec.o lib/arch/ssse3/codec.o lib/arch/sse41/codec.o lib/arch/sse42/codec.o lib/arch/avx/codec.o lib/lib.o lib/codec_choose.o lib/tables/tables.o
objcopy --keep-global-symbols=lib/exports.build.txt lib/libbase64.o
make: objcopy: No such file or directory
make: *** [lib/libbase64.o] Error 1

Never heard of objcopy before; looks like it's part of a GNU Binary Utilities library. I'm not sure if this tool supports macOS, i.e. Mach-O executables, or how to install it if it does.

(I'm running macOS 14.3.1 on an M1 MacBook Pro.)

snej commented 5 months ago

I just noticed that CMake is supported, and builds fine for me, so I'll be using that instead of make. It would still be nice if the Makefile were made compatible.

aklomp commented 5 months ago

The objcopy step is not really necessary and can be commented out. It hides any symbols not listed in lib/exports.build.txt, so that internal symbols are not exposed by accident.

The objcopy step is a bit of a hack and shouldn't be necessary once symbol visibility is handled by good design and language features. See also #54.

Keeping this issue open as a reminder that the Makefile build is broken on MacOS.