Revert "Unbloat build config"

This reverts commit ae5d06dc53.
This commit is contained in:
Justine Tunney 2022-08-10 12:44:56 -07:00
parent 95f54eeb40
commit c1d99676c4
1421 changed files with 5556 additions and 2198 deletions

View file

@ -75,7 +75,7 @@ o/$(MODE)/tool/build/build.pkg: \
o/$(MODE)/%.ctest.ok: \
%.ctest \
$(TOOL_BUILD_CALCULATOR)
@$(COMPILE) -wAMKWIDES -tT$@ $(TOOL_BUILD_CALCULATOR) $<
@$(COMPILE) -AMKWIDES -tT$@ $(TOOL_BUILD_CALCULATOR) $<
o/$(MODE)/tool/build/%.com.dbg: \
$(TOOL_BUILD_DEPS) \
@ -90,21 +90,21 @@ o/$(MODE)/tool/build/emulator.o: \
-fno-sanitize=pointer-overflow
o/$(MODE)/tool/build/mkdir.zip.o: o/$(MODE)/tool/build/mkdir
@$(COMPILE) -wAZIPOBJ $(ZIPOBJ) $(ZIPOBJ_FLAGS) -0 -B -Pbin $(OUTPUT_OPTION) $<
@$(COMPILE) -AZIPOBJ $(ZIPOBJ) $(ZIPOBJ_FLAGS) -0 -B -Pbin $(OUTPUT_OPTION) $<
o/$(MODE)/tool/build/chmod.zip.o: o/$(MODE)/tool/build/chmod
@$(COMPILE) -wAZIPOBJ $(ZIPOBJ) $(ZIPOBJ_FLAGS) -0 -B -Pbin $(OUTPUT_OPTION) $<
@$(COMPILE) -AZIPOBJ $(ZIPOBJ) $(ZIPOBJ_FLAGS) -0 -B -Pbin $(OUTPUT_OPTION) $<
o/$(MODE)/tool/build/cp.zip.o: o/$(MODE)/tool/build/cp
@$(COMPILE) -wAZIPOBJ $(ZIPOBJ) $(ZIPOBJ_FLAGS) -0 -B -Pbin $(OUTPUT_OPTION) $<
@$(COMPILE) -AZIPOBJ $(ZIPOBJ) $(ZIPOBJ_FLAGS) -0 -B -Pbin $(OUTPUT_OPTION) $<
o/$(MODE)/tool/build/mv.zip.o: o/$(MODE)/tool/build/mv
@$(COMPILE) -wAZIPOBJ $(ZIPOBJ) $(ZIPOBJ_FLAGS) -0 -B -Pbin $(OUTPUT_OPTION) $<
@$(COMPILE) -AZIPOBJ $(ZIPOBJ) $(ZIPOBJ_FLAGS) -0 -B -Pbin $(OUTPUT_OPTION) $<
o/$(MODE)/tool/build/echo.zip.o: o/$(MODE)/tool/build/echo
@$(COMPILE) -wAZIPOBJ $(ZIPOBJ) $(ZIPOBJ_FLAGS) -0 -B -Pbin $(OUTPUT_OPTION) $<
@$(COMPILE) -AZIPOBJ $(ZIPOBJ) $(ZIPOBJ_FLAGS) -0 -B -Pbin $(OUTPUT_OPTION) $<
o/$(MODE)/tool/build/gzip.zip.o: o/$(MODE)/tool/build/gzip
@$(COMPILE) -wAZIPOBJ $(ZIPOBJ) $(ZIPOBJ_FLAGS) -0 -B -Pbin $(OUTPUT_OPTION) $<
@$(COMPILE) -AZIPOBJ $(ZIPOBJ) $(ZIPOBJ_FLAGS) -0 -B -Pbin $(OUTPUT_OPTION) $<
o/$(MODE)/tool/build/printf.zip.o: o/$(MODE)/tool/build/printf
@$(COMPILE) -wAZIPOBJ $(ZIPOBJ) $(ZIPOBJ_FLAGS) -0 -B -Pbin $(OUTPUT_OPTION) $<
@$(COMPILE) -AZIPOBJ $(ZIPOBJ) $(ZIPOBJ_FLAGS) -0 -B -Pbin $(OUTPUT_OPTION) $<
o/$(MODE)/tool/build/dd.zip.o: o/$(MODE)/tool/build/dd
@$(COMPILE) -wAZIPOBJ $(ZIPOBJ) $(ZIPOBJ_FLAGS) -0 -B -Pbin $(OUTPUT_OPTION) $<
@$(COMPILE) -AZIPOBJ $(ZIPOBJ) $(ZIPOBJ_FLAGS) -0 -B -Pbin $(OUTPUT_OPTION) $<
# we need pic because:
# so it can be an LD_PRELOAD payload
@ -125,9 +125,7 @@ o/$(MODE)/tool/build/dso/sandbox.so: \
o/$(MODE)/tool/build/dso/sandbox.o \
o/$(MODE)/libc/calls/pledge-linux.o \
o/$(MODE)/libc/sysv/restorert.o
@$(COMPILE) -ALINK.so -tT$@ \
$(CC) \
-s \
@$(CC) -s \
-shared \
-nostdlib \
-Wl,--gc-sections \
@ -138,7 +136,7 @@ o/$(MODE)/tool/build/dso/sandbox.so: \
o/$(MODE)/tool/build/dso/sandbox.so.zip.o: \
o/$(MODE)/tool/build/dso/sandbox.so
@$(COMPILE) -wAZIPOBJ $(ZIPOBJ) $(ZIPOBJ_FLAGS) -B $(OUTPUT_OPTION) $<
@$(COMPILE) -AZIPOBJ $(ZIPOBJ) $(ZIPOBJ_FLAGS) -B $(OUTPUT_OPTION) $<
o/$(MODE)/tool/build/pledge.com.dbg: \
$(TOOL_BUILD_DEPS) \

View file

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

View file

@ -91,11 +91,11 @@ o/$(MODE)/tool/build/lib/apetest2.com.dbg: \
o/$(MODE)/tool/build/lib/apetest.com.zip.o: \
o/$(MODE)/tool/build/lib/apetest.com
@$(COMPILE) -wAZIPOBJ $(ZIPOBJ) $(ZIPOBJ_FLAGS) -B $(OUTPUT_OPTION) $<
@$(COMPILE) -AZIPOBJ $(ZIPOBJ) $(ZIPOBJ_FLAGS) -B $(OUTPUT_OPTION) $<
o/$(MODE)/tool/build/lib/apetest2.com.zip.o: \
o/$(MODE)/tool/build/lib/apetest2.com
@$(COMPILE) -wAZIPOBJ $(ZIPOBJ) $(ZIPOBJ_FLAGS) -B $(OUTPUT_OPTION) $<
@$(COMPILE) -AZIPOBJ $(ZIPOBJ) $(ZIPOBJ_FLAGS) -B $(OUTPUT_OPTION) $<
o/$(MODE)/tool/build/lib/apetest.o: \
tool/build/lib/apetest.c \

View file

@ -18,7 +18,6 @@
*/
#include "libc/calls/struct/stat.h"
#include "libc/log/check.h"
#include "libc/mem/mem.h"
#include "libc/runtime/gc.internal.h"
#include "libc/sysv/consts/o.h"
#include "libc/x/x.h"

View file

@ -17,7 +17,6 @@
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/stdio/stdio.h"
#include "libc/str/str.h"
/**
* @fileoverview Sums per-line integers from stdin.

View file

@ -18,10 +18,8 @@
*/
#include "libc/calls/calls.h"
#include "libc/calls/syscall-sysv.internal.h"
#include "libc/dce.h"
#include "libc/intrin/kprintf.h"
#include "libc/log/bsd.h"
#include "libc/mem/mem.h"
#include "libc/runtime/runtime.h"
#include "libc/stdio/stdio.h"
#include "libc/str/str.h"
@ -29,7 +27,7 @@
#define USAGE \
"\
usage: unveil.com [-h] PROG ARGS...\n\
usage: pledge.com [-h] PROG ARGS...\n\
-h show help\n\
\n\
unveil.com v1.o\n\
@ -81,7 +79,7 @@ int main(int argc, char *argv[]) {
bool chomped = false;
while (!chomped)
if (line[len - 1] == '\r' || line[len - 1] == '\n')
if (line[len-1] == '\r' || line[len-1] == '\n')
line[--len] = '\0';
else
chomped = true;
@ -103,11 +101,11 @@ int main(int argc, char *argv[]) {
err(1, "unveil(%s, %s)", fields[0], fields[1]);
}
free(line);
if (ferror(stdin)) {
if (ferror(stdin))
err(1, "getline");
}
if (unveil(NULL, NULL) == -1) err(1, "unveil(NULL, NULL)");
if (unveil(NULL, NULL) == -1)
err(1, "unveil(NULL, NULL)");
__sys_execve(prog, argv + optind, environ);
err(127, "execve");

View file

@ -21,7 +21,6 @@
#include "libc/fmt/conv.h"
#include "libc/log/check.h"
#include "libc/math.h"
#include "libc/mem/mem.h"
#include "libc/runtime/gc.internal.h"
#include "libc/runtime/runtime.h"
#include "libc/stdio/stdio.h"