when linking without libc, build memcpy.o and memset.o. we can cache these objects with a hash of (release/debug, conditional compilation values, target triple/data layout).
generate a compile unit without memcpy/memset exported. when linking the final output, use ar rcs foo.a foo.o memcpy.o memset.o. Then ld -o foo foo.a (or equivalent).
This accomplishes several things:
- omit memcpy/memset when the functions are unused
- avoid compiling memcpy/memset with every compiler invocation
- allow linking zig-created .o files with libc .o files, so that a single project can have both c code and zig code and everything can be linked together. in this case zig generated code will depend on the libc memset/memcpy implementations.
when linking without libc, build memcpy.o and memset.o. we can cache these objects with a hash of (release/debug, conditional compilation values, target triple/data layout).
generate a compile unit without memcpy/memset exported. when linking the final output, use
ar rcs foo.a foo.o memcpy.o memset.o. Thenld -o foo foo.a(or equivalent).This accomplishes several things: