Avoid creating temporary output files

This change also removes the futimens() call on the Landlock Make output
file workaround, since it caused problems with commands like fixupobj
which modify-in-place. It turns out if a file is opened for writing and
then no writes actually occur, then the modified time doesn't change.
This commit is contained in:
Justine Tunney 2022-08-10 22:08:43 -07:00
parent 4c3ab6d11e
commit 2d64b9994b
15 changed files with 502 additions and 446 deletions

Binary file not shown.

View file

@ -27,4 +27,4 @@ o/$(MODE)/%.com.ok: \
o/$(MODE)/tool/build/runit.com \ o/$(MODE)/tool/build/runit.com \
o/$(MODE)/tool/build/runitd.com \ o/$(MODE)/tool/build/runitd.com \
o/$(MODE)/%.com o/$(MODE)/%.com
@$(COMPILE) -ATEST -tT$@ $^ $(HOSTS) @$(COMPILE) -wATEST -tT$@ $^ $(HOSTS)

View file

@ -20,15 +20,12 @@ o/%.o: %.s ; @$(COMPILE) -AOBJECTIFY.s $(OBJECTIFY.s) $(
o/%.o: o/%.s ; @$(COMPILE) -AOBJECTIFY.s $(OBJECTIFY.s) $(OUTPUT_OPTION) $< o/%.o: o/%.s ; @$(COMPILE) -AOBJECTIFY.s $(OBJECTIFY.s) $(OUTPUT_OPTION) $<
o/%.s: %.S ; @$(COMPILE) -APREPROCESS $(PREPROCESS) $(OUTPUT_OPTION) $< o/%.s: %.S ; @$(COMPILE) -APREPROCESS $(PREPROCESS) $(OUTPUT_OPTION) $<
o/%.s: o/%.S ; @$(COMPILE) -APREPROCESS $(PREPROCESS) $(OUTPUT_OPTION) $< o/%.s: o/%.S ; @$(COMPILE) -APREPROCESS $(PREPROCESS) $(OUTPUT_OPTION) $<
o/%.i: %.S ; @$(COMPILE) -APREPROCESS $(PREPROCESS) $(OUTPUT_OPTION) $<
o/%.o: %.S ; @$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) $< o/%.o: %.S ; @$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) $<
o/%.o: o/%.S ; @$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) $< o/%.o: o/%.S ; @$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) $<
o/%.s: %.i ; @$(COMPILE) -ACOMPILE.i $(COMPILE.i) $(OUTPUT_OPTION) $<
o/%.s: o/%.i ; @$(COMPILE) -ACOMPILE.i $(COMPILE.i) $(OUTPUT_OPTION) $<
o/%.lds: %.lds ; @$(COMPILE) -APREPROCESS $(PREPROCESS.lds) $(OUTPUT_OPTION) $< o/%.lds: %.lds ; @$(COMPILE) -APREPROCESS $(PREPROCESS.lds) $(OUTPUT_OPTION) $<
o/%.inc: %.h ; @$(COMPILE) -APREPROCESS $(PREPROCESS) $(OUTPUT_OPTION) -D__ASSEMBLER__ -P $< o/%.inc: %.h ; @$(COMPILE) -APREPROCESS $(PREPROCESS) $(OUTPUT_OPTION) -D__ASSEMBLER__ -P $<
o/%.greg.o: %.greg.c ; @$(COMPILE) -AOBJECTIFY.greg $(OBJECTIFY.greg.c) $(OUTPUT_OPTION) $< o/%.greg.o: %.greg.c ; @$(COMPILE) -AOBJECTIFY.greg $(OBJECTIFY.greg.c) $(OUTPUT_OPTION) $<
o/%.zip.o: o/% ; @$(COMPILE) -AZIPOBJ $(ZIPOBJ) $(ZIPOBJ_FLAGS) $(OUTPUT_OPTION) $< o/%.zip.o: o/% ; @$(COMPILE) -wAZIPOBJ $(ZIPOBJ) $(ZIPOBJ_FLAGS) $(OUTPUT_OPTION) $<
o/$(MODE)/%: o/$(MODE)/%.dbg ; @$(COMPILE) -AOBJCOPY -T$@ $(OBJCOPY) -S -O binary $< $@ o/$(MODE)/%: o/$(MODE)/%.dbg ; @$(COMPILE) -AOBJCOPY -T$@ $(OBJCOPY) -S -O binary $< $@
o/$(MODE)/%.o: %.s ; @$(COMPILE) -AOBJECTIFY.s $(OBJECTIFY.s) $(OUTPUT_OPTION) $< o/$(MODE)/%.o: %.s ; @$(COMPILE) -AOBJECTIFY.s $(OBJECTIFY.s) $(OUTPUT_OPTION) $<
@ -39,32 +36,21 @@ o/$(MODE)/%.o: %.f ; @$(COMPILE) -AOBJECTIFY.f $(OBJECTIFY.f) $(
o/$(MODE)/%.o: %.F ; @$(COMPILE) -AOBJECTIFY.F $(OBJECTIFY.F) $(OUTPUT_OPTION) $< o/$(MODE)/%.o: %.F ; @$(COMPILE) -AOBJECTIFY.F $(OBJECTIFY.F) $(OUTPUT_OPTION) $<
o/$(MODE)/%.ss: %.c ; @$(COMPILE) -ACOMPILE.c $(COMPILE.c) $(OUTPUT_OPTION) $< o/$(MODE)/%.ss: %.c ; @$(COMPILE) -ACOMPILE.c $(COMPILE.c) $(OUTPUT_OPTION) $<
o/$(MODE)/%.ss: o/$(MODE)/%.c ; @$(COMPILE) -AOBJECTIFY.s $(COMPILE.c) $(OUTPUT_OPTION) $< o/$(MODE)/%.ss: o/$(MODE)/%.c ; @$(COMPILE) -AOBJECTIFY.s $(COMPILE.c) $(OUTPUT_OPTION) $<
o/$(MODE)/%.i: %.S ; @$(COMPILE) -APREPROCESS $(PREPROCESS) $(OUTPUT_OPTION) $<
o/$(MODE)/%.i: %.c ; @$(COMPILE) -APREPROCESS $(PREPROCESS) $(OUTPUT_OPTION) $<
o/$(MODE)/%.i: %.cc ; @$(COMPILE) -APREPROCESS $(PREPROCESS) $(OUTPUT_OPTION) $<
o/$(MODE)/%.i: o/$(MODE)/%.c ; @$(COMPILE) -APREPROCESS $(PREPROCESS) $(OUTPUT_OPTION) $<
o/$(MODE)/%.h: %.c ; @$(COMPILE) -AAMALGAMATE $(PREPROCESS) $(OUTPUT_OPTION) -fdirectives-only -P $< o/$(MODE)/%.h: %.c ; @$(COMPILE) -AAMALGAMATE $(PREPROCESS) $(OUTPUT_OPTION) -fdirectives-only -P $<
o/$(MODE)/%.h: o/$(MODE)/%.c ; @$(COMPILE) -AAMALGAMATE $(PREPROCESS) $(OUTPUT_OPTION) -fdirectives-only -P $< o/$(MODE)/%.h: o/$(MODE)/%.c ; @$(COMPILE) -AAMALGAMATE $(PREPROCESS) $(OUTPUT_OPTION) -fdirectives-only -P $<
o/$(MODE)/%.o: %.S ; @$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) $< o/$(MODE)/%.o: %.S ; @$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) $<
o/$(MODE)/%.o: o/$(MODE)/%.S ; @$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) $< o/$(MODE)/%.o: o/$(MODE)/%.S ; @$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) $<
o/$(MODE)/%.s: %.i ; @$(COMPILE) -ACOMPILE.i $(COMPILE.i) $(OUTPUT_OPTION) $<
o/$(MODE)/%.s: o/$(MODE)/%.i ; @$(COMPILE) -ACOMPILE.i $(COMPILE.i) $(OUTPUT_OPTION) $<
o/$(MODE)/%.o: %.cc ; @$(COMPILE) -AOBJECTIFY.cxx $(OBJECTIFY.cxx) $(OUTPUT_OPTION) $< o/$(MODE)/%.o: %.cc ; @$(COMPILE) -AOBJECTIFY.cxx $(OBJECTIFY.cxx) $(OUTPUT_OPTION) $<
o/$(MODE)/%.lds: %.lds ; @$(COMPILE) -APREPROCESS $(PREPROCESS.lds) $(OUTPUT_OPTION) $< o/$(MODE)/%.lds: %.lds ; @$(COMPILE) -APREPROCESS $(PREPROCESS.lds) $(OUTPUT_OPTION) $<
o/$(MODE)/%.cxx.o: %.c ; @$(COMPILE) -AOBJECTIFY.cxx $(OBJECTIFY.cxx) -xc++ $(OUTPUT_OPTION) $< o/$(MODE)/%.cxx.o: %.c ; @$(COMPILE) -AOBJECTIFY.cxx $(OBJECTIFY.cxx) -xc++ $(OUTPUT_OPTION) $<
o/$(MODE)/%.o: %.greg.c ; @$(COMPILE) -AOBJECTIFY.greg $(OBJECTIFY.greg.c) $(OUTPUT_OPTION) $< o/$(MODE)/%.o: %.greg.c ; @$(COMPILE) -AOBJECTIFY.greg $(OBJECTIFY.greg.c) $(OUTPUT_OPTION) $<
o/$(MODE)/%.greg.o: %.greg.c ; @$(COMPILE) -AOBJECTIFY.greg $(OBJECTIFY.greg.c) $(OUTPUT_OPTION) $< o/$(MODE)/%.greg.o: %.greg.c ; @$(COMPILE) -AOBJECTIFY.greg $(OBJECTIFY.greg.c) $(OUTPUT_OPTION) $<
o/$(MODE)/%.ansi.o: %.ansi.c ; @$(COMPILE) -AOBJECTIFY.ansi $(OBJECTIFY.ansi.c) $(OUTPUT_OPTION) $<
o/$(MODE)/%.ansi.o: %.c ; @$(COMPILE) -AOBJECTIFY.ansi $(OBJECTIFY.ansi.c) $(OUTPUT_OPTION) $<
o/$(MODE)/%.c99.o: %.c99.c ; @$(COMPILE) -AOBJECTIFY.c99 $(OBJECTIFY.c99.c) $(OUTPUT_OPTION) $<
o/$(MODE)/%.c11.o: %.c11.c ; @$(COMPILE) -AOBJECTIFY.c11 $(OBJECTIFY.c11.c) $(OUTPUT_OPTION) $<
o/$(MODE)/%.c2x.o: %.c2x.c ; @$(COMPILE) -AOBJECTIFY.c2x $(OBJECTIFY.c2x.c) $(OUTPUT_OPTION) $<
o/$(MODE)/%.initabi.o: %.initabi.c ; @$(COMPILE) -AOBJECTIFY.init $(OBJECTIFY.initabi.c) $(OUTPUT_OPTION) $< o/$(MODE)/%.initabi.o: %.initabi.c ; @$(COMPILE) -AOBJECTIFY.init $(OBJECTIFY.initabi.c) $(OUTPUT_OPTION) $<
o/$(MODE)/%.ncabi.o: %.ncabi.c ; @$(COMPILE) -AOBJECTIFY.nc $(OBJECTIFY.ncabi.c) $(OUTPUT_OPTION) $< o/$(MODE)/%.ncabi.o: %.ncabi.c ; @$(COMPILE) -AOBJECTIFY.nc $(OBJECTIFY.ncabi.c) $(OUTPUT_OPTION) $<
o/$(MODE)/%.real.o: %.c ; @$(COMPILE) -AOBJECTIFY.real $(OBJECTIFY.real.c) $(OUTPUT_OPTION) $< o/$(MODE)/%.real.o: %.c ; @$(COMPILE) -AOBJECTIFY.real $(OBJECTIFY.real.c) $(OUTPUT_OPTION) $<
o/$(MODE)/%.runs: o/$(MODE)/% ; @$(COMPILE) -ACHECK -tT$@ $< $(TESTARGS) o/$(MODE)/%.runs: o/$(MODE)/% ; @$(COMPILE) -ACHECK -tT$@ $< $(TESTARGS)
o/$(MODE)/%.zip.o: % ; @$(COMPILE) -AZIPOBJ $(ZIPOBJ) $(ZIPOBJ_FLAGS) $(OUTPUT_OPTION) $< o/$(MODE)/%.zip.o: % ; @$(COMPILE) -wAZIPOBJ $(ZIPOBJ) $(ZIPOBJ_FLAGS) $(OUTPUT_OPTION) $<
o/$(MODE)/%-gcc.asm: %.c ; @$(COMPILE) -AOBJECTIFY.c $(OBJECTIFY.c) -S -g0 $(OUTPUT_OPTION) $< o/$(MODE)/%-gcc.asm: %.c ; @$(COMPILE) -AOBJECTIFY.c $(OBJECTIFY.c) -S -g0 $(OUTPUT_OPTION) $<
o/$(MODE)/%-gcc.asm: %.cc ; @$(COMPILE) -AOBJECTIFY.c $(OBJECTIFY.cxx) -S -g0 $(OUTPUT_OPTION) $< o/$(MODE)/%-gcc.asm: %.cc ; @$(COMPILE) -AOBJECTIFY.c $(OBJECTIFY.cxx) -S -g0 $(OUTPUT_OPTION) $<
o/$(MODE)/%-clang.asm: %.c ; @$(COMPILE) -AOBJECTIFY.c $(OBJECTIFY.c) -S -g0 $(OUTPUT_OPTION) $< o/$(MODE)/%-clang.asm: %.c ; @$(COMPILE) -AOBJECTIFY.c $(OBJECTIFY.c) -S -g0 $(OUTPUT_OPTION) $<
@ -73,66 +59,66 @@ o/$(MODE)/%-clang.asm: CC = $(CLANG)
o/%.o: %.cc o/%.o: %.cc
@$(COMPILE) -AOBJECTIFY.cxx $(OBJECTIFY.cxx) $(OUTPUT_OPTION) $< @$(COMPILE) -AOBJECTIFY.cxx $(OBJECTIFY.cxx) $(OUTPUT_OPTION) $<
@$(COMPILE) -AFIXUPOBJ -T$@ $(FIXUPOBJ) $@ @$(COMPILE) -AFIXUPOBJ -wT$@ $(FIXUPOBJ) $@
o/%.o: o/%.cc o/%.o: o/%.cc
@$(COMPILE) -AOBJECTIFY.cxx $(OBJECTIFY.cxx) $(OUTPUT_OPTION) $< @$(COMPILE) -AOBJECTIFY.cxx $(OBJECTIFY.cxx) $(OUTPUT_OPTION) $<
@$(COMPILE) -AFIXUPOBJ -T$@ $(FIXUPOBJ) $@ @$(COMPILE) -AFIXUPOBJ -wT$@ $(FIXUPOBJ) $@
o/$(MODE)/%.o: %.c o/$(MODE)/%.o: %.c
@$(COMPILE) -AOBJECTIFY.c $(OBJECTIFY.c) $(OUTPUT_OPTION) $< @$(COMPILE) -AOBJECTIFY.c $(OBJECTIFY.c) $(OUTPUT_OPTION) $<
@$(COMPILE) -AFIXUPOBJ -T$@ $(FIXUPOBJ) $@ @$(COMPILE) -AFIXUPOBJ -wT$@ $(FIXUPOBJ) $@
o/$(MODE)/%.o: o/$(MODE)/%.c o/$(MODE)/%.o: o/$(MODE)/%.c
@$(COMPILE) -AOBJECTIFY.c $(OBJECTIFY.c) $(OUTPUT_OPTION) $< @$(COMPILE) -AOBJECTIFY.c $(OBJECTIFY.c) $(OUTPUT_OPTION) $<
@$(COMPILE) -AFIXUPOBJ -T$@ $(FIXUPOBJ) $@ @$(COMPILE) -AFIXUPOBJ -wT$@ $(FIXUPOBJ) $@
o/$(MODE)/%.o: o/$(MODE)/%.cc o/$(MODE)/%.o: o/$(MODE)/%.cc
@$(COMPILE) -AOBJECTIFY.cxx $(OBJECTIFY.cxx) $(OUTPUT_OPTION) $< @$(COMPILE) -AOBJECTIFY.cxx $(OBJECTIFY.cxx) $(OUTPUT_OPTION) $<
@$(COMPILE) -AFIXUPOBJ -T$@ $(FIXUPOBJ) $@ @$(COMPILE) -AFIXUPOBJ -wT$@ $(FIXUPOBJ) $@
o/%.a: o/%.a:
$(file >$(TMPDIR)/$(subst /,_,$@),$^) $(file >$(TMPDIR)/$(subst /,_,$@),$^)
@$(COMPILE) -AARCHIVE -T$@ $(AR) $(ARFLAGS) $@ @$(TMPDIR)/$(subst /,_,$@) @$(COMPILE) -AARCHIVE -wT$@ $(AR) $(ARFLAGS) $@ @$(TMPDIR)/$(subst /,_,$@)
o/%.pkg: o/%.pkg:
$(file >$(TMPDIR)/$(subst /,_,$@).args,$(filter %.o,$^)) $(file >$(TMPDIR)/$(subst /,_,$@).args,$(filter %.o,$^))
@$(COMPILE) -APACKAGE -T$@ $(PKG) $(OUTPUT_OPTION) $(addprefix -d,$(filter %.pkg,$^)) @$(TMPDIR)/$(subst /,_,$@) @$(COMPILE) -APACKAGE -wT$@ $(PKG) $(OUTPUT_OPTION) $(addprefix -d,$(filter %.pkg,$^)) @$(TMPDIR)/$(subst /,_,$@)
o/$(MODE)/%.pkg: o/$(MODE)/%.pkg:
$(file >$(TMPDIR)/$(subst /,_,$@),$(filter %.o,$^)) $(file >$(TMPDIR)/$(subst /,_,$@),$(filter %.o,$^))
@$(COMPILE) -APACKAGE -T$@ $(PKG) $(OUTPUT_OPTION) $(addprefix -d,$(filter %.pkg,$^)) @$(TMPDIR)/$(subst /,_,$@) @$(COMPILE) -APACKAGE -wT$@ $(PKG) $(OUTPUT_OPTION) $(addprefix -d,$(filter %.pkg,$^)) @$(TMPDIR)/$(subst /,_,$@)
o/$(MODE)/%.o: %.py o/$(MODE)/third_party/python/pyobj.com o/$(MODE)/%.o: %.py o/$(MODE)/third_party/python/pyobj.com
@$(COMPILE) -APYOBJ o/$(MODE)/third_party/python/pyobj.com $(PYFLAGS) -o $@ $< @$(COMPILE) -wAPYOBJ o/$(MODE)/third_party/python/pyobj.com $(PYFLAGS) -o $@ $<
o/$(MODE)/%.pyc: %.py o/$(MODE)/third_party/python/pycomp.com o/$(MODE)/%.pyc: %.py o/$(MODE)/third_party/python/pycomp.com
@$(COMPILE) -APYCOMP o/$(MODE)/third_party/python/pycomp.com $(PYCFLAGS) -o $@ $< @$(COMPILE) -wAPYCOMP o/$(MODE)/third_party/python/pycomp.com $(PYCFLAGS) -o $@ $<
o/$(MODE)/%.lua: %.lua o/$(MODE)/third_party/lua/luac.com o/$(MODE)/%.lua: %.lua o/$(MODE)/third_party/lua/luac.com
@$(COMPILE) -ALUAC o/$(MODE)/third_party/lua/luac.com -s -o $@ $< @$(COMPILE) -wALUAC o/$(MODE)/third_party/lua/luac.com -s -o $@ $<
o/$(MODE)/%.lua.runs: %.lua o/$(MODE)/tool/net/redbean.com o/$(MODE)/%.lua.runs: %.lua o/$(MODE)/tool/net/redbean.com
@$(COMPILE) -ALUA -tT$@ o/$(MODE)/tool/net/redbean.com $(LUAFLAGS) -i $< @$(COMPILE) -wALUA -tT$@ o/$(MODE)/tool/net/redbean.com $(LUAFLAGS) -i $<
o/$(MODE)/%: o/$(MODE)/%.com o/$(MODE)/tool/build/cp.com o/$(MODE)/tool/build/assimilate.com o/$(MODE)/%: o/$(MODE)/%.com o/$(MODE)/tool/build/cp.com o/$(MODE)/tool/build/assimilate.com
@$(COMPILE) -ACP -T$@ o/$(MODE)/tool/build/cp.com $< $@ @$(COMPILE) -wACP -T$@ o/$(MODE)/tool/build/cp.com $< $@
@$(COMPILE) -AASSIMILATE -T$@ o/$(MODE)/tool/build/assimilate.com $@ @$(COMPILE) -wAASSIMILATE -T$@ o/$(MODE)/tool/build/assimilate.com $@
# TODO(jart): find a way to generate dependencies # TODO(jart): find a way to generate dependencies
# or alternatively disable sandboxing # or alternatively disable sandboxing
o/%.h.ok: %.h o/%.h.ok: %.h
@$(COMPILE) -ACHECK.h -T$@ build/bootstrap/touch.com $@ @$(COMPILE) -wACHECK.h -T$@ build/bootstrap/touch.com $@
# @$(COMPILE) -ACHECK.h $(COMPILE.c) -xc -g0 -o $@ $< # @$(COMPILE) -ACHECK.h $(COMPILE.c) -xc -g0 -o $@ $<
o/$(MODE)/%.h.ok: %.h o/$(MODE)/%.h.ok: %.h
@$(COMPILE) -ACHECK.h -T$@ build/bootstrap/touch.com $@ @$(COMPILE) -wACHECK.h -T$@ build/bootstrap/touch.com $@
# @$(COMPILE) -ACHECK.h $(COMPILE.c) -xc -g0 -o $@ $< # @$(COMPILE) -ACHECK.h $(COMPILE.c) -xc -g0 -o $@ $<
o/$(MODE)/%.hh.ok: %.hh o/$(MODE)/%.hh.ok: %.hh
@$(COMPILE) -ACHECK.h -T$@ build/bootstrap/touch.com $@ @$(COMPILE) -wACHECK.h -T$@ build/bootstrap/touch.com $@
# @$(COMPILE) -ACHECK.h $(COMPILE.cxx) -xc++ -g0 -o $@ $< # @$(COMPILE) -ACHECK.h $(COMPILE.cxx) -xc++ -g0 -o $@ $<
o/%.okk: % o/%.okk: %
@$(COMPILE) -ACHECK.h -T$@ build/bootstrap/touch.com $@ @$(COMPILE) -wACHECK.h -T$@ build/bootstrap/touch.com $@
# @$(COMPILE) -ACHECK.h $(COMPILE.cxx) -xc++ -g0 -o $@ $< # @$(COMPILE) -ACHECK.h $(COMPILE.cxx) -xc++ -g0 -o $@ $<
o/$(MODE)/%.okk: % o/$(MODE)/%.okk: %
@$(COMPILE) -ACHECK.h -T$@ build/bootstrap/touch.com $@ @$(COMPILE) -wACHECK.h -T$@ build/bootstrap/touch.com $@
# @$(COMPILE) -ACHECK.h $(COMPILE.cxx) -xc++ -g0 -o $@ $< # @$(COMPILE) -ACHECK.h $(COMPILE.cxx) -xc++ -g0 -o $@ $<

View file

@ -89,11 +89,11 @@ o/$(MODE)/test/libc/mem/prog/life.com.dbg: \
o/$(MODE)/test/libc/mem/prog/life.elf: \ o/$(MODE)/test/libc/mem/prog/life.elf: \
o/$(MODE)/tool/build/assimilate.com \ o/$(MODE)/tool/build/assimilate.com \
o/$(MODE)/test/libc/mem/prog/life.com o/$(MODE)/test/libc/mem/prog/life.com
@$(COMPILE) -ACP -T$@ \ @$(COMPILE) -wACP -T$@ \
build/bootstrap/cp.com \ build/bootstrap/cp.com \
o/$(MODE)/test/libc/mem/prog/life.com \ o/$(MODE)/test/libc/mem/prog/life.com \
o/$(MODE)/test/libc/mem/prog/life.elf o/$(MODE)/test/libc/mem/prog/life.elf
@$(COMPILE) -AASSIMILATE -T$@ \ @$(COMPILE) -wAASSIMILATE -T$@ \
o/$(MODE)/tool/build/assimilate.com \ o/$(MODE)/tool/build/assimilate.com \
o/$(MODE)/test/libc/mem/prog/life.elf o/$(MODE)/test/libc/mem/prog/life.elf
@ -114,11 +114,11 @@ o/$(MODE)/test/libc/mem/prog/sock.com.dbg: \
o/$(MODE)/test/libc/mem/prog/sock.elf: \ o/$(MODE)/test/libc/mem/prog/sock.elf: \
o/$(MODE)/tool/build/assimilate.com \ o/$(MODE)/tool/build/assimilate.com \
o/$(MODE)/test/libc/mem/prog/sock.com o/$(MODE)/test/libc/mem/prog/sock.com
@$(COMPILE) -ACP -T$@ \ @$(COMPILE) -wACP -T$@ \
build/bootstrap/cp.com \ build/bootstrap/cp.com \
o/$(MODE)/test/libc/mem/prog/sock.com \ o/$(MODE)/test/libc/mem/prog/sock.com \
o/$(MODE)/test/libc/mem/prog/sock.elf o/$(MODE)/test/libc/mem/prog/sock.elf
@$(COMPILE) -AASSIMILATE -T$@ \ @$(COMPILE) -wAASSIMILATE -T$@ \
o/$(MODE)/tool/build/assimilate.com \ o/$(MODE)/tool/build/assimilate.com \
o/$(MODE)/test/libc/mem/prog/sock.elf o/$(MODE)/test/libc/mem/prog/sock.elf

View file

@ -65,7 +65,7 @@ o/$(MODE)/test/libc/nexgen32e/stackrwx_test.com.ok: \
o/$(MODE)/tool/build/runit.com \ o/$(MODE)/tool/build/runit.com \
o/$(MODE)/tool/build/runitd.com \ o/$(MODE)/tool/build/runitd.com \
o/$(MODE)/test/libc/nexgen32e/stackrwx_test.com o/$(MODE)/test/libc/nexgen32e/stackrwx_test.com
@$(COMPILE) -ATEST -tT$@ $^ $(filter-out openbsd,$(HOSTS)) @$(COMPILE) -wATEST -tT$@ $^ $(filter-out openbsd,$(HOSTS))
$(TEST_LIBC_NEXGEN32E_OBJS): private \ $(TEST_LIBC_NEXGEN32E_OBJS): private \
DEFAULT_CCFLAGS += \ DEFAULT_CCFLAGS += \

View file

@ -88,7 +88,7 @@ o/$(MODE)/test/libc/release/smoke-chibicc.o: \
test/libc/release/smoke.c \ test/libc/release/smoke.c \
o/cosmopolitan.h \ o/cosmopolitan.h \
o/$(MODE)/third_party/chibicc/chibicc.com o/$(MODE)/third_party/chibicc/chibicc.com
@$(COMPILE) -ACHIBICC \ @$(COMPILE) -wACHIBICC \
o/$(MODE)/third_party/chibicc/chibicc.com \ o/$(MODE)/third_party/chibicc/chibicc.com \
$(CHIBICC_FLAGS) \ $(CHIBICC_FLAGS) \
-o $@ \ -o $@ \

View file

@ -72,7 +72,7 @@ o/$(MODE)/third_party/chibicc/test/%.com.dbg: \
o/$(MODE)/third_party/chibicc/test/%.o: \ o/$(MODE)/third_party/chibicc/test/%.o: \
third_party/chibicc/test/%.c \ third_party/chibicc/test/%.c \
$(CHIBICC) $(CHIBICC)
@$(COMPILE) -AOBJECTIFY.c $(CHIBICC) $(CHIBICC_FLAGS) $(OUTPUT_OPTION) -c $< @$(COMPILE) -wAOBJECTIFY.c $(CHIBICC) $(CHIBICC_FLAGS) $(OUTPUT_OPTION) -c $<
o/$(MODE)/third_party/chibicc/test/int128_test.o: private QUOTA = -M1024m o/$(MODE)/third_party/chibicc/test/int128_test.o: private QUOTA = -M1024m

View file

@ -122,39 +122,39 @@ THIRD_PARTY_DOUBLECONVERSION_TEST_RUNS = \
o/$(MODE)/third_party/double-conversion/test-strtod.runs: \ o/$(MODE)/third_party/double-conversion/test-strtod.runs: \
o/$(MODE)/third_party/double-conversion/double-conversion-tester.com o/$(MODE)/third_party/double-conversion/double-conversion-tester.com
@$(COMPILE) -ACHECK -tT$@ $< test-strtod @$(COMPILE) -ACHECK -wtT$@ $< test-strtod
o/$(MODE)/third_party/double-conversion/test-ieee.runs: \ o/$(MODE)/third_party/double-conversion/test-ieee.runs: \
o/$(MODE)/third_party/double-conversion/double-conversion-tester.com o/$(MODE)/third_party/double-conversion/double-conversion-tester.com
@$(COMPILE) -ACHECK -tT$@ $< test-ieee @$(COMPILE) -ACHECK -wtT$@ $< test-ieee
o/$(MODE)/third_party/double-conversion/test-fixed-dtoa.runs: \ o/$(MODE)/third_party/double-conversion/test-fixed-dtoa.runs: \
o/$(MODE)/third_party/double-conversion/double-conversion-tester.com o/$(MODE)/third_party/double-conversion/double-conversion-tester.com
@$(COMPILE) -ACHECK -tT$@ $< test-fixed-dtoa @$(COMPILE) -ACHECK -wtT$@ $< test-fixed-dtoa
o/$(MODE)/third_party/double-conversion/test-fast-dtoa.runs: \ o/$(MODE)/third_party/double-conversion/test-fast-dtoa.runs: \
o/$(MODE)/third_party/double-conversion/double-conversion-tester.com o/$(MODE)/third_party/double-conversion/double-conversion-tester.com
@$(COMPILE) -ACHECK -tT$@ $< test-fast-dtoa @$(COMPILE) -ACHECK -wtT$@ $< test-fast-dtoa
o/$(MODE)/third_party/double-conversion/test-dtoa.runs: \ o/$(MODE)/third_party/double-conversion/test-dtoa.runs: \
o/$(MODE)/third_party/double-conversion/double-conversion-tester.com o/$(MODE)/third_party/double-conversion/double-conversion-tester.com
@$(COMPILE) -ACHECK -tT$@ $< test-dtoa @$(COMPILE) -ACHECK -wtT$@ $< test-dtoa
o/$(MODE)/third_party/double-conversion/test-diy-fp.runs: \ o/$(MODE)/third_party/double-conversion/test-diy-fp.runs: \
o/$(MODE)/third_party/double-conversion/double-conversion-tester.com o/$(MODE)/third_party/double-conversion/double-conversion-tester.com
@$(COMPILE) -ACHECK -tT$@ $< test-diy-fp @$(COMPILE) -ACHECK -wtT$@ $< test-diy-fp
o/$(MODE)/third_party/double-conversion/test-conversions.runs: \ o/$(MODE)/third_party/double-conversion/test-conversions.runs: \
o/$(MODE)/third_party/double-conversion/double-conversion-tester.com o/$(MODE)/third_party/double-conversion/double-conversion-tester.com
@$(COMPILE) -ACHECK -tT$@ $< test-conversions @$(COMPILE) -ACHECK -wtT$@ $< test-conversions
o/$(MODE)/third_party/double-conversion/test-bignum-dtoa.runs: \ o/$(MODE)/third_party/double-conversion/test-bignum-dtoa.runs: \
o/$(MODE)/third_party/double-conversion/double-conversion-tester.com o/$(MODE)/third_party/double-conversion/double-conversion-tester.com
@$(COMPILE) -ACHECK -tT$@ $< test-bignum-dtoa @$(COMPILE) -ACHECK -wtT$@ $< test-bignum-dtoa
o/$(MODE)/third_party/double-conversion/test-bignum.runs: \ o/$(MODE)/third_party/double-conversion/test-bignum.runs: \
o/$(MODE)/third_party/double-conversion/double-conversion-tester.com o/$(MODE)/third_party/double-conversion/double-conversion-tester.com
@$(COMPILE) -ACHECK -tT$@ $< test-bignum @$(COMPILE) -ACHECK -wtT$@ $< test-bignum
THIRD_PARTY_DOUBLECONVERSION_LIBS = $(foreach x,$(THIRD_PARTY_DOUBLECONVERSION_ARTIFACTS),$($(x))) THIRD_PARTY_DOUBLECONVERSION_LIBS = $(foreach x,$(THIRD_PARTY_DOUBLECONVERSION_ARTIFACTS),$($(x)))
THIRD_PARTY_DOUBLECONVERSION_SRCS = $(foreach x,$(THIRD_PARTY_DOUBLECONVERSION_ARTIFACTS),$($(x)_SRCS)) THIRD_PARTY_DOUBLECONVERSION_SRCS = $(foreach x,$(THIRD_PARTY_DOUBLECONVERSION_ARTIFACTS),$($(x)_SRCS))

View file

@ -1866,10 +1866,7 @@ child_execute_job (struct childbase *child, int good_stdin, char **argv)
errno = err; errno = err;
fd = open (c->file->name, O_RDWR | O_CREAT, 0777); fd = open (c->file->name, O_RDWR | O_CREAT, 0777);
if (fd != -1) if (fd != -1)
{ close (fd);
futimens (fd, (struct timespec[2]){0});
close (fd);
}
else if (errno == EEXIST) else if (errno == EEXIST)
errno = err; errno = err;
else else

View file

@ -137,7 +137,7 @@ o/$(MODE)/third_party/mbedtls/test/%.com: o/$(MODE)/third_party/mbedtls/test/%.c
@$(COMPILE) -AOBJCOPY -T$@ $(OBJCOPY) -S -O binary $< $@ @$(COMPILE) -AOBJCOPY -T$@ $(OBJCOPY) -S -O binary $< $@
o/$(MODE)/third_party/mbedtls/test/%.com.runs: o/$(MODE)/third_party/mbedtls/test/%.com o/$(MODE)/third_party/mbedtls/test/%.com.runs: o/$(MODE)/third_party/mbedtls/test/%.com
@$(COMPILE) -ACHECK -tT$@ $< $(TESTARGS) @$(COMPILE) -ACHECK -wtT$@ $< $(TESTARGS)
$(THIRD_PARTY_MBEDTLS_TEST_OBJS): private \ $(THIRD_PARTY_MBEDTLS_TEST_OBJS): private \
OVERRIDE_CFLAGS += \ OVERRIDE_CFLAGS += \

File diff suppressed because it is too large Load diff

View file

@ -132,12 +132,12 @@ THIRD_PARTY_QUICKJS_CHECKS = \
o/$(MODE)/third_party/quickjs/qjscalc.c: \ o/$(MODE)/third_party/quickjs/qjscalc.c: \
third_party/quickjs/qjscalc.js \ third_party/quickjs/qjscalc.js \
o/$(MODE)/third_party/quickjs/qjsc.com o/$(MODE)/third_party/quickjs/qjsc.com
@$(COMPILE) -AQJSC o/$(MODE)/third_party/quickjs/qjsc.com -fbignum -o $@ -c $< @$(COMPILE) -wAQJSC o/$(MODE)/third_party/quickjs/qjsc.com -fbignum -o $@ -c $<
o/$(MODE)/third_party/quickjs/repl.c: \ o/$(MODE)/third_party/quickjs/repl.c: \
third_party/quickjs/repl.js \ third_party/quickjs/repl.js \
o/$(MODE)/third_party/quickjs/qjsc.com o/$(MODE)/third_party/quickjs/qjsc.com
@$(COMPILE) -AQJSC o/$(MODE)/third_party/quickjs/qjsc.com -o $@ -m -c $< @$(COMPILE) -wAQJSC o/$(MODE)/third_party/quickjs/qjsc.com -o $@ -m -c $<
o/$(MODE)/third_party/quickjs/qjs.com.dbg: \ o/$(MODE)/third_party/quickjs/qjs.com.dbg: \
$(THIRD_PARTY_QUICKJS) \ $(THIRD_PARTY_QUICKJS) \

View file

@ -87,7 +87,7 @@ o/$(MODE)/tool/build/build.pkg: \
o/$(MODE)/%.ctest.ok: \ o/$(MODE)/%.ctest.ok: \
%.ctest \ %.ctest \
$(TOOL_BUILD_CALCULATOR) $(TOOL_BUILD_CALCULATOR)
@$(COMPILE) -AMKWIDES -tT$@ $(TOOL_BUILD_CALCULATOR) $< @$(COMPILE) -AMKWIDES -wtT$@ $(TOOL_BUILD_CALCULATOR) $<
o/$(MODE)/tool/build/%.com.dbg: \ o/$(MODE)/tool/build/%.com.dbg: \
$(TOOL_BUILD_DEPS) \ $(TOOL_BUILD_DEPS) \

View file

@ -16,6 +16,7 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE. PERFORMANCE OF THIS SOFTWARE.
*/ */
#include "libc/alg/alg.h"
#include "libc/bits/bits.h" #include "libc/bits/bits.h"
#include "libc/bits/safemacros.internal.h" #include "libc/bits/safemacros.internal.h"
#include "libc/calls/calls.h" #include "libc/calls/calls.h"
@ -41,6 +42,7 @@
#include "libc/mem/mem.h" #include "libc/mem/mem.h"
#include "libc/nexgen32e/kcpuids.h" #include "libc/nexgen32e/kcpuids.h"
#include "libc/nexgen32e/x86feature.h" #include "libc/nexgen32e/x86feature.h"
#include "libc/runtime/gc.internal.h"
#include "libc/runtime/runtime.h" #include "libc/runtime/runtime.h"
#include "libc/runtime/sysconf.h" #include "libc/runtime/sysconf.h"
#include "libc/stdio/append.internal.h" #include "libc/stdio/append.internal.h"
@ -49,6 +51,7 @@
#include "libc/sysv/consts/auxv.h" #include "libc/sysv/consts/auxv.h"
#include "libc/sysv/consts/clock.h" #include "libc/sysv/consts/clock.h"
#include "libc/sysv/consts/itimer.h" #include "libc/sysv/consts/itimer.h"
#include "libc/sysv/consts/madv.h"
#include "libc/sysv/consts/o.h" #include "libc/sysv/consts/o.h"
#include "libc/sysv/consts/rlimit.h" #include "libc/sysv/consts/rlimit.h"
#include "libc/sysv/consts/s.h" #include "libc/sysv/consts/s.h"
@ -109,6 +112,7 @@ FLAGS\n\
-s decrement verbosity [default 4]\n\ -s decrement verbosity [default 4]\n\
-v increments verbosity [default 4]\n\ -v increments verbosity [default 4]\n\
-n do nothing (prime ape executable)\n\ -n do nothing (prime ape executable)\n\
-w disable landlock tmp workaround\n\
-h print help\n\ -h print help\n\
\n\ \n\
ENVIRONMENT\n\ ENVIRONMENT\n\
@ -144,6 +148,7 @@ bool wantfentry;
bool wantrecord; bool wantrecord;
bool fulloutput; bool fulloutput;
bool touchtarget; bool touchtarget;
bool noworkaround;
bool wantnoredzone; bool wantnoredzone;
bool stdoutmustclose; bool stdoutmustclose;
bool no_sanitize_null; bool no_sanitize_null;
@ -711,6 +716,8 @@ void ReportResources(void) {
bool MovePreservingDestinationInode(const char *from, const char *to) { bool MovePreservingDestinationInode(const char *from, const char *to) {
bool res; bool res;
ssize_t rc;
size_t remain;
struct stat st; struct stat st;
int fdin, fdout; int fdin, fdout;
if ((fdin = open(from, O_RDONLY)) == -1) { if ((fdin = open(from, O_RDONLY)) == -1) {
@ -721,7 +728,30 @@ bool MovePreservingDestinationInode(const char *from, const char *to) {
close(fdin); close(fdin);
return false; return false;
} }
res = _copyfd(fdin, fdout, -1) != -1; fadvise(fdin, 0, st.st_size, MADV_SEQUENTIAL);
ftruncate(fdout, st.st_size);
for (res = true, remain = st.st_size; remain;) {
rc = copy_file_range(fdin, 0, fdout, 0, remain, 0);
if (rc != -1) {
remain -= rc;
} else if (errno == EXDEV) {
if (lseek(fdin, 0, SEEK_SET) == -1) {
kprintf("%s: failed to lseek after exdev\n", from);
res = false;
break;
}
if (lseek(fdout, 0, SEEK_SET) == -1) {
kprintf("%s: failed to lseek after exdev\n", to);
res = false;
break;
}
res = _copyfd(fdin, fdout, -1) != -1;
break;
} else {
res = false;
break;
}
}
close(fdin); close(fdin);
close(fdout); close(fdout);
return res; return res;
@ -747,6 +777,23 @@ bool IsNativeExecutable(const char *path) {
return res; return res;
} }
char *MakeTmpOut(const char *path) {
int c;
char *p = tmpout;
char *e = tmpout + sizeof(tmpout) - 1;
p = stpcpy(p, kTmpPath);
while ((c = *path++)) {
if (c == '/') c = '_';
if (p == e) {
kprintf("MakeTmpOut path too long: %s\n", tmpout);
exit(1);
}
*p++ = c;
}
*p = 0;
return tmpout;
}
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
int columns; int columns;
uint64_t us; uint64_t us;
@ -757,7 +804,6 @@ int main(int argc, char *argv[]) {
char *s, *p, *q, **envp; char *s, *p, *q, **envp;
mode = firstnonnull(getenv("MODE"), MODE); mode = firstnonnull(getenv("MODE"), MODE);
ksnprintf(tmpout, sizeof(tmpout), "%scompile.%d", kTmpPath, getpid());
/* /*
* parse prefix arguments * parse prefix arguments
@ -769,7 +815,7 @@ int main(int argc, char *argv[]) {
fszquota = 256 * 1000 * 1000; /* bytes */ fszquota = 256 * 1000 * 1000; /* bytes */
memquota = 512 * 1024 * 1024; /* bytes */ memquota = 512 * 1024 * 1024; /* bytes */
if ((s = getenv("V"))) verbose = atoi(s); if ((s = getenv("V"))) verbose = atoi(s);
while ((opt = getopt(argc, argv, "hnstvA:C:F:L:M:O:P:T:V:")) != -1) { while ((opt = getopt(argc, argv, "hnstvwA:C:F:L:M:O:P:T:V:")) != -1) {
switch (opt) { switch (opt) {
case 'n': case 'n':
exit(0); exit(0);
@ -788,6 +834,9 @@ int main(int argc, char *argv[]) {
case 't': case 't':
touchtarget = true; touchtarget = true;
break; break;
case 'w':
noworkaround = true;
break;
case 'L': case 'L':
timeout = atoi(optarg); timeout = atoi(optarg);
break; break;
@ -856,17 +905,37 @@ int main(int argc, char *argv[]) {
* ingest arguments * ingest arguments
*/ */
for (i = optind; i < argc; ++i) { for (i = optind; i < argc; ++i) {
if (!movepath && !outpath && target && !strcmp(target, argv[i])) {
outpath = argv[i]; /*
AddArg(tmpout); * replace output filename argument
*
* some commands (e.g. ar) don't use the `-o PATH` notation. in that
* case we assume the output path was passed to compile.com -TTARGET
* which means we can replace the appropriate command line argument.
*/
if (!noworkaround && //
!movepath && //
!outpath && //
target && //
!strcmp(target, argv[i])) {
AddArg(MakeTmpOut(argv[i]));
outpath = target;
movepath = target; movepath = target;
MovePreservingDestinationInode(target, tmpout); MovePreservingDestinationInode(target, tmpout);
continue; continue;
} }
/*
* capture arguments
*/
if (argv[i][0] != '-') { if (argv[i][0] != '-') {
AddArg(argv[i]); AddArg(argv[i]);
continue; continue;
} }
/*
* capture flags
*/
if (startswith(argv[i], "-o")) { if (startswith(argv[i], "-o")) {
if (!strcmp(argv[i], "-o")) { if (!strcmp(argv[i], "-o")) {
outpath = argv[++i]; outpath = argv[++i];
@ -874,8 +943,12 @@ int main(int argc, char *argv[]) {
outpath = argv[i] + 2; outpath = argv[i] + 2;
} }
AddArg("-o"); AddArg("-o");
AddArg(tmpout); if (noworkaround) {
movepath = outpath; AddArg(outpath);
} else {
movepath = outpath;
AddArg(MakeTmpOut(outpath));
}
continue; continue;
} }
if (!iscc) { if (!iscc) {

View file

@ -116,8 +116,8 @@ o/$(MODE)/tool/net/redbean.com: \
o/$(MODE)/tool/net/redbean.com.dbg \ o/$(MODE)/tool/net/redbean.com.dbg \
o/$(MODE)/tool/build/symtab.com o/$(MODE)/tool/build/symtab.com
@$(COMPILE) -AOBJCOPY -T$@ $(OBJCOPY) -S -O binary $< $@ @$(COMPILE) -AOBJCOPY -T$@ $(OBJCOPY) -S -O binary $< $@
@$(COMPILE) -ASYMTAB o/$(MODE)/tool/build/symtab.com -o $(SYMTAB) $< @$(COMPILE) -wASYMTAB o/$(MODE)/tool/build/symtab.com -o $(SYMTAB) $<
@$(COMPILE) -AZIP -T$@ $@ -A $(SYMTAB) @$(COMPILE) -wAZIP -T$@ $@ -A $(SYMTAB)
# REDBEAN-DEMO.COM # REDBEAN-DEMO.COM
# #
@ -229,8 +229,8 @@ o/$(MODE)/tool/net/redbean-demo.com: \
o/$(MODE)/tool/net/redbean-demo.com.dbg \ o/$(MODE)/tool/net/redbean-demo.com.dbg \
o/$(MODE)/tool/build/symtab.com o/$(MODE)/tool/build/symtab.com
@$(COMPILE) -AOBJCOPY -T$@ $(OBJCOPY) -S -O binary $< $@ @$(COMPILE) -AOBJCOPY -T$@ $(OBJCOPY) -S -O binary $< $@
@$(COMPILE) -ASYMTAB o/$(MODE)/tool/build/symtab.com -o $(SYMTAB) $< @$(COMPILE) -wASYMTAB o/$(MODE)/tool/build/symtab.com -o $(SYMTAB) $<
@$(COMPILE) -AZIP -T$@ $@ -A $(SYMTAB) @$(COMPILE) -wAZIP -T$@ $@ -A $(SYMTAB)
# REDBEAN-STATIC.COM # REDBEAN-STATIC.COM
# #