Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Non-sucking Win32 C compiler

Name: Anonymous 2009-08-12 14:37

I need a small (not bloated to hell, clean, not system ruining / service installing) compiler for tiny C programs with POSIX-like semantics (i.e. C library that doesn't suck and stuff like read() instead of ReadFileWEX(WHANDLE, WSHARINGMODE, WSECURITYCONTEXT, NULL, NULL, NULL, NULL) - true POSIX stuff like fork() et al is not needed).

Visual Studio or cygwin are out of the question. Some GCC distro like mingw might be OK depending on how much the installation sucks (ideally there wouldn't be any installation at all).

Any ideas or do I give up to ENTERPRISE-quality software?

Name: Anonymous 2009-08-14 15:02

>>39
So it's .5 seconds instead of .05 seconds? Shocking.

Name: =+=*=F=R=O=Z=E=N==V=O=I=D=*=+= !frozEn/KIg 2009-08-14 15:10

>>41
Introduction
TCCBOOT is a boot loader able to compile and boot a Linux kernel directly from its source code.

TCCBOOT is only 138 KB big (uncompressed code) and it can compile and run a typical Linux kernel in less than 15 seconds on a 2.4 GHz Pentium 4.

TCCBOOT is based on the TinyCC compiler, assembler and linker. TinyCC is an experiment to produce a very small and simple C compiler compatible with the GNU C compiler and binary utilities.



______________________________________
http://xs135.xs.to/xs135/09042/av922.jpg
Velox Et Astrum gamedev forum: http://etastrum.phpbb3now.com
Go with your fate, but not beyond. Beyond leads to dark places.

Name: =+=*=F=R=O=Z=E=N==V=O=I=D=*=+= !frozEn/KIg 2009-08-14 15:12

http://bellard.org/tcc/tccboot.html



___________________________________
http://xs135.xs.to/xs135/09042/av922.jpg
Velox Et Astrum gamedev forum: http://etastrum.phpbb3now.com
The knowable world is incomplete if seen from any one point of view, incoherent if seen from all points of view at once, and empty if seen from nowhere in particular.

Name: Anonymous 2009-08-14 15:58

>>40
They did that because Pascal doesn't have enough features. I don't understand this, because that's why pascal is good, but whatever.

Name: Anonymous 2009-08-14 16:31

>>44
Pascal was an interpreted language at the time, so the real question is why the fuck they wrote it in Pascal to begin with.

Name: Anonymous 2009-08-14 16:52

>>45
I'm pretty sure Pastel was compiled, dude. Stallman originally wrote it in Pastel because he was just extending an existing (Pastel) compiler rather than writing his own from scratch.

Name: Anonymous 2009-08-14 17:22

>>46
Traditionally Pascal was compiled into P-code and run with a P-code interpreter.

Name: !Anus3nMVO2 2009-08-14 17:28

>>46
AIBT?

Name: =+=*=F=R=O=Z=E=N==V=O=I=D=*=+= !frozEn/KIg 2009-08-14 17:33

>>48 http://en.wikipedia.org/wiki/GNU_Compiler_Collection#History



____________________________________________
http://xs135.xs.to/xs135/09042/av922.jpg
Velox Et Astrum gamedev forum: http://etastrum.phpbb3now.com
We suffer primarily not from our vices or our weaknesses, but from our illusions.

Name: Anonymous 2009-08-14 17:56

>>47
There were a lot of Pascal dialects that weren't compiled to p-code, and Pastel was one of them.

Name: Anonymous 2009-08-14 18:17

>>15
I lol'd. By the way - goddamnit, fucking Spinoza.

Name: Anonymous 2009-08-15 5:16

The original aim of the TCC is to create a simple and small compiler to compile GCC.

Now here's a riddle: Can you guess why?

Name: Anonymous 2009-08-15 5:27

>>52
The requirements for a C compiler to compile GCC are far smaller than using GCC, a complete compiler that intends to target everything under the sun.

Name: Anonymous 2009-08-15 5:31

>>53
Hax  my anus, niggerfaggot.

Name: Anonymous 2009-08-15 5:37

>>53
Not quite but that's related.

TCC is so small it can be audited after assembly. The TCCBOOT script is also relevant. The answer is that it's meant to provide a way for creating a secure tool-chain. See work by Ken Thompson.

Name: Anonymous 2009-08-15 6:56

>>55
Although after compiling gcc with tcc, you should then compile gcc with the tcc-compiled gcc, since tcc's output is SHIT in terms of efficiency (very simple first-use limited-scope register allocation only for temporaries, everything kept on stack, etc.)

Name: Anonymous 2009-08-15 7:55

>>56
Sharp thinking. You should submit your idea to the GCC developer mailing list.

Name: =+=*=F=R=O=Z=E=N==V=O=I=D=*=+= !frozEn/KIg 2009-08-15 9:40

>>56 You should check Digital Mars C and PellesC which optimize code much more.
I use TCC as described in >>38



________________________________________
http://xs135.xs.to/xs135/09042/av922.jpg
Velox Et Astrum gamedev forum: http://etastrum.phpbb3now.com
If I want to understand something, I must observe, I must not criticize, I must not condemn, I must not pursue it as pleasure or avoid it as non-pleasure. There must merely be the silent observation of a fact.

Name: Anonymous 2009-08-15 9:43

Name: Anonymous 2009-08-15 20:07

>>58
i can't stop lolling.
YOU are interested in code optimization? hahahahaha.
bullshit. you write the most inefficient code i've ever seen.
for example, i've seen you write something very similar to this:
for(; i < (strlen(str1) > strlen(str2)? strlen(str2): strlen(str1)); ++i)
   str1[i] == str2[i];

your code is truly laughable, and this little snippet is just the tip of the iceberg.
what makes it even funnier is that you're completely dokyun

Name: Anonymous 2009-08-15 21:10

>>60
You do realize that because of this he stands to gain the most out of nearly any programmer from optimization right? Will an optimizing compiler move strlen calls outside the loop invariant? Yes. Will it memoize the strlen calls, or even just the comparison result? Yes. That is of course, if it can determine the loop body doesn't change the result of the strlen calls, and I would put money on that being the case for any non-shit compiler (assuming the == was meant to be =).

Name: Anonymous 2009-08-15 21:28

>>61
Another person who thinks optimising compilers are magic wands. Prepare to lose that money.

It doesn't matter, anyway, since FV thinks TCC is an optimising compiler.

Name: Anonymous 2009-08-15 21:45

>>62
I have personally tested this optimization on gcc in the past. If you are invoking the standard strlen function, gcc knows beforehand that it is pure. Figuring out that the null terminator in str1 will never get overwritten then should be trivial.

Name: Anonymous 2009-08-15 21:56

>>61
no.
how does the compiler know that the functions don't increment a static variable or somesuch and need to be called every iteration?
it doesn't.
compilers are not magic

Name: Anonymous 2009-08-15 22:02

Just download the window SDK.  It's almost a fucking xcopy for an install.. It supports POSIX api's (like just about every version from NT4).  And it builds Win32 code as you are, for some reason, asking for.

Oh.. and Posix is _Open,  OpenFile(..) is Win16 and CreateFile(..) is Win32.  The difference is about 2 parameters and CreateFile gives you a useful Win32 handle.

Learn about what you're writing before you actually start (facepalm).

Name: Anonymous 2009-08-15 22:07

>>63
It can know that strlen is pure and use that for some optimisations, but it won't step through your code to the extent required to turn the code in >>60 into non-sucking code. Rather than being ``trivial'', the sort of optimisations you have in mind are equivalent to solving the halting problem.

If it did do something like that for you, chances are you were in one of the rare situations were a C string was actually immutable (and I don't mean const char*). That's not the case in >>60.

Name: Anonymous 2009-08-15 22:40

>>66
You completely misunderstand both the halting problem and this one. The difference here is that the compiler has a higher order view of the inner workings of whatever you give it. It does not have some magical black box and has to return 1 or 0 based on whether the black box halts on given input or not. It can analyze inside the black box and determine for itself.

compiler: is strlen pure? yes
compiler: will str1[i] = str2[i] ever change the invariant?
compiler: will "i" ever exceed the length of str1?
compiler: no, the invariant is bounded above by strlen(str1)
compiler: therefore str1[i] = str2[i] will never overwrite the null terminator
compiler: therefore neither strlen changes
compiler: the loop invariant must never change
compiler: i can optimize this out

Find where the halting problem is solved please.

Name: Anonymous 2009-08-15 22:57

>>67
What happens when str1 or str2 are in shared memory?

The point isn't even that you can tailor-make a compiler to deal with a specific piece of shared code; that's plainly obvious and completely irrelevant.

Name: Anonymous 2009-08-15 23:02

>>66
It can know that strlen is pure and use that for some optimisations
Yanno, I wish C was better about letting you write explicitly pure functions (and forcing them to actually be pure). I heard Ada does this with the function vs. procedure keywords, and if you use the former you can't modify anything outside of local scope.

Name: Anonymous 2009-08-15 23:22

>>68
It doesn't matter if they are in shared memory, the compiler has already determined no null terminator will get written so it doesn't really change anything, it's hardly tailor made.

Name: Anonymous 2009-08-15 23:49

>>70
If your ``optimization'' changes what an algorithm actually does, it's not an optimization. Nor is it something any compilers will actually do.

Name: Anonymous 2009-08-15 23:49

>>70
What? What if you put a null-terminator before the current one?

Name: Anonymous 2009-08-16 0:48

nomatter what strlen optimisations are offered by the compiler, there is still the plain fact that the code could easily be written without calls to strlen.
allow me to demonstrate. something like this would be much more efficient:
while(*str1 && *str2)
   *str1++ = *str2++;

Name: Anonymous 2009-08-16 1:52

>>73
while(*str1++ = *str2++);

Name: Anonymous 2009-08-16 2:24

>>74
buffer overflow if str1 was smaller than str2.

Name: Anonymous 2009-08-16 2:24

>>75
Minor side effect.

Name: Anonymous 2009-08-16 2:40

while (*str1 && *str1 = *str2); should be kosher.

Name: Anonymous 2009-08-16 2:49

>>77
infinite loop if neither string is empty.

Name: Anonymous 2009-08-16 2:50

(assuming you put in the parentheses so it even compiles)

Name: Anonymous 2009-08-16 2:56

>>78
What's that even supposed to mean?

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List