From 4f75a74c2c4a5f5df7d097c11b5631727a401ac8 Mon Sep 17 00:00:00 2001 From: turbocat Date: Sun, 19 Jun 2022 15:47:00 +0000 Subject: [PATCH] libc.obj: now builded to kos32-tcc git-svn-id: svn://kolibrios.org@9843 a494cfbc-eb01-0410-851d-a64ba20cac60 --- .../ktcc/trunk/libc.obj/source/Tupfile.lua | 45 +++++++++++++++---- .../develop/ktcc/trunk/libc.obj/source/libc.c | 31 ------------- .../ktcc/trunk/libc.obj/source/math/sqrt.asm | 9 ---- .../ktcc/trunk/libc.obj/source/math/sqrt.s | 8 ++++ .../ktcc/trunk/libc.obj/source/math/tan.asm | 10 ----- .../ktcc/trunk/libc.obj/source/math/tan.s | 16 +++++++ .../trunk/libc.obj/source/stdlib/assert.c | 7 +-- .../ktcc/trunk/libc.obj/source/time/asctime.c | 6 +-- 8 files changed, 63 insertions(+), 69 deletions(-) delete mode 100644 programs/develop/ktcc/trunk/libc.obj/source/math/sqrt.asm create mode 100644 programs/develop/ktcc/trunk/libc.obj/source/math/sqrt.s delete mode 100644 programs/develop/ktcc/trunk/libc.obj/source/math/tan.asm create mode 100644 programs/develop/ktcc/trunk/libc.obj/source/math/tan.s diff --git a/programs/develop/ktcc/trunk/libc.obj/source/Tupfile.lua b/programs/develop/ktcc/trunk/libc.obj/source/Tupfile.lua index 3d75b66e6e..baa36e97d4 100755 --- a/programs/develop/ktcc/trunk/libc.obj/source/Tupfile.lua +++ b/programs/develop/ktcc/trunk/libc.obj/source/Tupfile.lua @@ -3,16 +3,45 @@ if tup.getconfig("NO_GCC") ~= "" then return end HELPERDIR = (tup.getconfig("HELPERDIR") == "") and "../../../../../" or tup.getconfig("HELPERDIR") tup.include(HELPERDIR .. "/use_gcc.lua") -CFLAGS = " -c -nostdinc -DGNUC -D_BUILD_LIBC -Os -fno-common -fno-builtin -fno-leading-underscore -fno-pie" +CFLAGS = " -r -nostdinc -nostdlib -DGNUC -D_BUILD_LIBC " INCLUDES = " -I../include" -OBJS = {"math/tan.obj", "math/sqrt.obj"} +GAS_SRC = { + "setjmp/setjmp.s", + "setjmp/longjmp.s", + "math/round.s", + "math/atan.s", + "math/pow2.s", + "math/log10.s", + "math/exp.s", + "math/pow10.s", + "math/log.s", + "math/pow.s", + "math/ceil.s", + "math/cos.s", + "math/sin.s", + "math/asin.s", + "math/modf.s", + "math/floor.s", + "math/fabs.s", + "math/fmod.s", + "math/log2.s", + "math/acos.s", + "math/modfl.s", + "math/atan2.s", + "math/sqrt.s", + "math/tan.s", + "string/memset.s", + "string/memmove.s" +} -for _, OBJ in pairs(OBJS) do - tup.rule(string.gsub(OBJ, ".obj", ".asm"), "fasm %f %o ", OBJ) -end +OBJS = {} -tup.rule("libc.c", "kos32-gcc" .. CFLAGS .. INCLUDES .. " -o %o %f ", "libc_tmp.obj") +tup.append_table(OBJS, + tup.foreach_rule(GAS_SRC, "as --32 %f -o %o", "%B.o") +) -table.insert(OBJS, "libc_tmp.obj"); -tup.rule(OBJS, "clink -o %o %f" .. " && kos32-strip %o --strip-unneeded " .. tup.getconfig("KPACK_CMD"), "libc.obj"); +table.insert(OBJS, "libc.c"); + +tup.rule(OBJS, "kos32-tcc" .. CFLAGS .. INCLUDES .. " -o %o %f " .. " && strip %o --strip-unneeded " , "libc.o") +tup.rule("libc.o", "objconv -fcoff32 %f %o " .. tup.getconfig("KPACK_CMD"), "%B.obj") diff --git a/programs/develop/ktcc/trunk/libc.obj/source/libc.c b/programs/develop/ktcc/trunk/libc.obj/source/libc.c index f724d7728b..d53280f7a7 100644 --- a/programs/develop/ktcc/trunk/libc.obj/source/libc.c +++ b/programs/develop/ktcc/trunk/libc.obj/source/libc.c @@ -119,37 +119,6 @@ #include "misc/basename.c" #include "misc/dirname.c" -__asm__( - ".include \"math/acos.s\"\n\t" - ".include \"math/asin.s\"\n\t" - ".include \"math/atan.s\"\n\t" - ".include \"math/atan2.s\"\n\t" - ".include \"math/ceil.s\"\n\t" - ".include \"math/cos.s\"\n\t" - ".include \"math/exp.s\"\n\t" - ".include \"math/fabs.s\"\n\t" - ".include \"math/floor.s\"\n\t" - ".include \"math/fmod.s\"\n\t" - ".include \"math/log.s\"\n\t" - ".include \"math/log2.s\"\n\t" - ".include \"math/log10.s\"\n\t" - ".include \"math/modf.s\"\n\t" - ".include \"math/modfl.s\"\n\t" - ".include \"math/pow.s\"\n\t" - ".include \"math/pow2.s\"\n\t" - ".include \"math/pow10.s\"\n\t" - ".include \"math/round.s\"\n\t" - ".include \"math/sin.s\"\n\t"); - -__asm__( - ".include \"string/memmove.s\"\n\t" - ".include \"string/memset.s\"\n\t" - ".include \"setjmp/longjmp.s\"\n\t" - ".include \"setjmp/setjmp.s\""); - -#include "libtcc1/libtcc1.c" -#include "stdlib/___chkstk_ms.c" - ksys_dll_t EXPORTS[] = { { "clearerr", &clearerr }, { "debug_printf", &debug_printf }, diff --git a/programs/develop/ktcc/trunk/libc.obj/source/math/sqrt.asm b/programs/develop/ktcc/trunk/libc.obj/source/math/sqrt.asm deleted file mode 100644 index c537ea8486..0000000000 --- a/programs/develop/ktcc/trunk/libc.obj/source/math/sqrt.asm +++ /dev/null @@ -1,9 +0,0 @@ -format COFF -section '.text' - -public _sqrt as "sqrt" - -_sqrt: - fld qword[esp+4] - fsqrt - ret diff --git a/programs/develop/ktcc/trunk/libc.obj/source/math/sqrt.s b/programs/develop/ktcc/trunk/libc.obj/source/math/sqrt.s new file mode 100644 index 0000000000..4011a53852 --- /dev/null +++ b/programs/develop/ktcc/trunk/libc.obj/source/math/sqrt.s @@ -0,0 +1,8 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ + +.global sqrt; + +sqrt: + fldl 4(%esp) + fsqrt + ret diff --git a/programs/develop/ktcc/trunk/libc.obj/source/math/tan.asm b/programs/develop/ktcc/trunk/libc.obj/source/math/tan.asm deleted file mode 100644 index 0cdf5c4cee..0000000000 --- a/programs/develop/ktcc/trunk/libc.obj/source/math/tan.asm +++ /dev/null @@ -1,10 +0,0 @@ -format COFF -section '.text' - -public _tan as "tan" - -_tan: - fld qword[esp+4] - fptan - fxch - ret diff --git a/programs/develop/ktcc/trunk/libc.obj/source/math/tan.s b/programs/develop/ktcc/trunk/libc.obj/source/math/tan.s new file mode 100644 index 0000000000..5101c4ffbf --- /dev/null +++ b/programs/develop/ktcc/trunk/libc.obj/source/math/tan.s @@ -0,0 +1,16 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ + +tan.L0: + .quad 0xffffffffffffffff + +tan: + fldl 4(%esp) + fptan + fstsw + fstp %st(0) + sahf + jnp tan.L1 +/* fstp %st(0) - if exception, there is nothing on the stack */ + fldl tan.L0 +tan.L1: + ret diff --git a/programs/develop/ktcc/trunk/libc.obj/source/stdlib/assert.c b/programs/develop/ktcc/trunk/libc.obj/source/stdlib/assert.c index 7efb8001c4..a767504e2f 100644 --- a/programs/develop/ktcc/trunk/libc.obj/source/stdlib/assert.c +++ b/programs/develop/ktcc/trunk/libc.obj/source/stdlib/assert.c @@ -1,13 +1,8 @@ #include #include -#pragma GCC push_options -#pragma GCC optimize("O0") - void __assert_fail(const char* expr, const char* file, int line, const char* func) { fprintf(stdout, "Assertion failed: %s (%s: %s: %d)\n", expr, file, func, line); exit(0); -} - -#pragma GCC pop_options \ No newline at end of file +} \ No newline at end of file diff --git a/programs/develop/ktcc/trunk/libc.obj/source/time/asctime.c b/programs/develop/ktcc/trunk/libc.obj/source/time/asctime.c index 3996ae511a..4ca7cb5624 100644 --- a/programs/develop/ktcc/trunk/libc.obj/source/time/asctime.c +++ b/programs/develop/ktcc/trunk/libc.obj/source/time/asctime.c @@ -7,9 +7,6 @@ const char* wday_str[7] = { "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun" }; const char* mon_str[12] = { "Jan", "Feb", "Mar", "Ap", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; -#pragma GCC push_options -#pragma GCC optimize("O0") - #define TIME_STR_MAX 27 char* asctime(const struct tm* tm) @@ -30,5 +27,4 @@ char* asctime(const struct tm* tm) tm->tm_min, tm->tm_sec, 1900 + tm->tm_year); return time_str; -} -#pragma GCC pop_options +} \ No newline at end of file