Make build hermetic without shell scripts

- Fix some minor issues in ar.com
- Have execve() look for `ape` command
- Rewrite NT paths using /c/ rather /??/c:/
- Replace broken GCC symlinks with .sym files
- Rewrite $PATH environment variables on startup
- Make $(APE_NO_MODIFY_SELF) the default bootloader
- Add all build command dependencies to build/bootstrap
- Get the repository mostly building from source on non-Linux
This commit is contained in:
Justine Tunney 2022-05-25 11:31:08 -07:00
parent d44ff6ce1f
commit d230a01222
160 changed files with 2754 additions and 1342 deletions

View file

@ -35,7 +35,7 @@ TEST(clock_gettime, test) {
ASSERT_NE(0, ts.tv_sec);
ASSERT_NE(0, ts.tv_nsec);
if (__is_linux_2_6_23()) {
ASSERT_GT((intptr_t)__get_clock_gettime(&isfast),
ASSERT_GT((intptr_t)__clock_gettime_get(&isfast),
getauxval(AT_SYSINFO_EHDR));
ASSERT_TRUE(isfast);
}

View file

@ -45,5 +45,5 @@ TEST(getcwd, testWindows_addsFunnyPrefix) {
if (!IsWindows()) return;
char path[PATH_MAX];
ASSERT_NE(0, getcwd(path, sizeof(path)));
EXPECT_STARTSWITH("//?/", path);
EXPECT_STARTSWITH("/C/", path);
}

View file

@ -20,17 +20,18 @@
#include "libc/runtime/gc.internal.h"
#include "libc/testlib/testlib.h"
char tmp[ARG_MAX];
char16_t envvars[ARG_MAX / 2];
TEST(mkntenvblock, emptyList_onlyOutputsDoubleNulStringTerminator) {
char *envp[] = {NULL};
ASSERT_NE(-1, mkntenvblock(envvars, envp, NULL));
ASSERT_NE(-1, mkntenvblock(envvars, envp, NULL, tmp));
ASSERT_BINEQ(u"  ", envvars);
}
TEST(mkntenvblock, envp_becomesSortedDoubleNulTerminatedUtf16String) {
char *envp[] = {"u=b", "c=d", "韩=非", "uh=d", "hduc=d", NULL};
ASSERT_NE(-1, mkntenvblock(envvars, envp, NULL));
ASSERT_NE(-1, mkntenvblock(envvars, envp, NULL, tmp));
ASSERT_BINEQ(u"C = d   "
u"H D U C = d   "
u"U = b   "
@ -42,7 +43,7 @@ TEST(mkntenvblock, envp_becomesSortedDoubleNulTerminatedUtf16String) {
TEST(mkntenvblock, extraVar_getsAdded) {
char *envp[] = {"u=b", "c=d", "韩=非", "uh=d", "hduc=d", NULL};
ASSERT_NE(-1, mkntenvblock(envvars, envp, "a=a"));
ASSERT_NE(-1, mkntenvblock(envvars, envp, "a=a", tmp));
ASSERT_BINEQ(u"A = a   "
u"C = d   "
u"H D U C = d   "
@ -52,3 +53,11 @@ TEST(mkntenvblock, extraVar_getsAdded) {
u"  ",
envvars);
}
TEST(mkntenvblock, pathvars_getUpdated) {
char *envp[] = {"PATH=/c/foo:/d/bar", NULL};
ASSERT_NE(-1, mkntenvblock(envvars, envp, 0, tmp));
ASSERT_BINEQ(u"P A T H = c : \\ f o o ; d : \\ b a r   "
u"  ",
envvars);
}

View file

@ -101,9 +101,10 @@ TEST(readlinkat, statReadsNameLength) {
}
TEST(readlinkat, realpathReturnsLongPath) {
if (!IsWindows()) return;
struct stat st;
char buf[PATH_MAX];
if (!IsWindows()) return;
if (!startswith(getcwd(buf, PATH_MAX), "/c/")) return;
ASSERT_SYS(0, 0, touch("froot", 0644));
ASSERT_STARTSWITH("//?/", realpath("froot", buf));
ASSERT_STARTSWITH("/c/", realpath("froot", buf));
}

View file

@ -61,7 +61,7 @@ o/$(MODE)/test/libc/calls/%.com.dbg: \
o/$(MODE)/test/libc/calls/calls.pkg \
$(LIBC_TESTMAIN) \
$(CRT) \
$(APE)
$(APE_NO_MODIFY_SELF)
@$(APELINK)
.PHONY: o/$(MODE)/test/libc/calls