drh / lcc Goto Github PK
View Code? Open in Web Editor NEWThe lcc retargetable ANSI C compiler
Home Page: https://drh.github.io/lcc/
The lcc retargetable ANSI C compiler
Home Page: https://drh.github.io/lcc/
This hierarchy is the distribution for lcc version 4.2. lcc version 3.x is described in the book "A Retargetable C Compiler: Design and Implementation" (Addison-Wesley, 1995, ISBN 0-8053-1670-1). There are significant differences between 3.x and 4.x, most notably in the intermediate code. For details, see http://storage.webhop.net/documents/interface4.pdf. VERSION 4.2 IS INCOMPATIBLE WITH EARLIER VERSIONS OF LCC. DO NOT UNLOAD THIS DISTRIBUTION ON TOP OF A 3.X DISTRIBUTION. LCC is a C89 ("ANSI C") compiler designed to be highly retargetable. LOG describes the changes since the last release. CPYRIGHT describes the conditions under you can use, copy, modify, and distribute lcc or works derived from lcc. doc/install.html is an HTML file that gives a complete description of the distribution and installation instructions. Chris Fraser / [email protected] David Hanson / [email protected] $Revision$ $Date$
The src/*.md files have some issue where all are cloned from the github repository incorrectly.
This manifests, when trying to compile dagcheck.c, with the error messages:
line 1: invalid character `%'
line 1: invalid character `{'
line 1: invalid character `\015'
line 2: invalid character `#'
line 2: syntax error
line 2: invalid character `\015'
line 3: syntax error
line 3: invalid character `;'
line 3: invalid character `\015'
line 4: invalid character `#'
...
This might be something related to me using WSL, but I was tipped off to the issue by this google groups post: here.
Workaround is to download all the *.md files through the github "raw" web interface for each file.
Lcc will compile this code incorrectly, making the pointer in the struct iter_obj passed to iterate become NULL when it really isn't supposed too.
#include <stdio.h>
struct iter_obj
{
void *iterable;
};
#define new_iter_obj(iter) {iter}
void *array_item(int index, void *iterable)
{
if (index < 10)
{
return (void *) &(((int *) iterable)[index]);
}
else
{
return NULL;
}
}
void iterate(struct iter_obj *obj)
{
void *tmp;
int index = 0;
/* obj->iterable == NULL, but it should point to countdown in main */
while ((tmp = array_item(index, obj->iterable)) != NULL)
{
printf("%d\n", *((int *) tmp));
index++;
}
}
int main()
{
int countdown[10] = {10, 9, 8, 7, 6, 5, 4, 3, 2, 1};
/* cd_iter.iterable == countdown */
struct iter_obj cd_iter = new_iter_obj((void *) countdown);
iterate(&cd_iter);
}
Hi Dave,
In src/stmt.c line no. 151,
Type rty definition should be at top in statement function (for C89)
Type rty = freturn(cfunc->type);
Warm Regards,
Daipayan Bhowal
After trying to compile lcc for Windows it gave me errors because of missing files.
I tried compiling by using mingw32-make
and the Open Watcom nmake
clone. Both gave different errors, but they both were missing some files.
I searched for precompiled binaries but couldn't find any anywhere.
As I mentioned in the title, I want to do my own compilation using your compiler, and is it my programming language by playing in c libraries? I've tried Java proactively from you, but my programming language is not compatible with the slogan of slogan "C as powerful as python is so easy", according to the information I've read on the internet,
1-) your compiler is not borrowed like borland c, right?
2-) Not compatible with all operating systems?
3-) is not the c compiler we know?
Now why do I order them
Because of the question, sordum wikipedia is licensed. For saying
2. The question on the link to ask you about the question is #34
3. Due to the fact that the sordium has been called the processor programming compiler for some sites c programming language
I apologize for writing so long):
main.c has an incorrect length for the mulops_calls option string on lines 158 and 159.
else if (strncmp(argv[i], "-mulops_calls=", 18) == 0) IR->mulops_calls = argv[i][18] - '0';
should be:
else if (strncmp(argv[i], "-mulops_calls=", 14) == 0) IR->mulops_calls = argv[i][14] - '0';
if I'm counting correctly.
---------- Forwarded message ---------
From: nikonsmith [email protected]
Date: Mon, Jul 20, 2015 at 10:49 PM
Subject: lcc's cpp bug
To: [email protected] [email protected]
cpp bug:
when I compile a c source file which have a line that much than 32KB, it then print `Input buffer overflow' and exit process.
for example, I write a program generate a c source file that 100KB in one line,as follow:
/* generate.c */
int code_len = 100*1024; // 100KB c source code
int main(void) {
char *str="int a%04d=10;";
int str_len = 13;
int str_nr = code_len / str_len;
int i;
for(i=0;i<str_nr;i++) {
printf(str,i);
}
printf("\nint main(void) { return 0; }\n");
return 0;
}
$ ./generate > 100k.c
$ lcc -v 100k.c
cpp: 100k.c:1 Input buffer overflow
Getting an ASAN SEGV report. To reproduce, I just compiled with asan enabled on x86 machine Linux. To reproduce:
./rcc -target=x86/linux file.c , where file.c the following piece of C code:
int main()
{
printf("Hello World\n");
return 0;
}
Here I attach the full ASAN report
==3559653==ERROR: AddressSanitizer: SEGV on unknown address (pc 0x0000007ae8e3 bp 0x000000001015 sp 0x7fffffffcf20 T0)
==3559653==The signal is caused by a READ memory access.
==3559653==Hint: this fault was caused by a dereference of a high value address (see register values below). Disassemble the provided pc to learn which register was used.
#0 0x7ae8e3 in listnodes /home/elmanto/mnt/output/lcc/src/dag.c:176:35
#1 0x7ade35 in listnodes /home/elmanto/mnt/output/lcc/src/dag.c:333:13
#2 0x7a8f32 in walk /home/elmanto/mnt/output/lcc/src/dag.c:40:2
#3 0x55cfc7 in retcode /home/elmanto/mnt/output/lcc/src/stmt.c:543:2
#4 0x557d46 in statement /home/elmanto/mnt/output/lcc/src/stmt.c
#5 0x4da11c in compound /home/elmanto/mnt/output/lcc/src/decl.c:858:3
#6 0x4d5d35 in funcdefn /home/elmanto/mnt/output/lcc/src/decl.c:769:2
#7 0x4d5d35 in decl /home/elmanto/mnt/output/lcc/src/decl.c:167:5
#8 0x4d0b4a in program /home/elmanto/mnt/output/lcc/src/decl.c:40:4
#9 0x4cd190 in main /home/elmanto/mnt/output/lcc/src/main.c:81:2
#10 0x7ffff7c4f0b2 in __libc_start_main /build/glibc-eX1tMB/glibc-2.31/csu/../csu/libc-start.c:308:16
#11 0x41d3fd in _start (/home/elmanto/mnt/output/build_lcc/rcc+0x41d3fd)
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV /home/elmanto/mnt/output/lcc/src/dag.c:176:35 in listnodes
==3559653==ABORTING
A quick internet search found http://www.willus.com/ccomp_benchmark.shtml?p1 which is from 2002
I'd like to get a feeling for how much faster LCC compiles compared to GCC and how much slower the executables run. Obviously this is application specific but I'd like to set some expectations of what might be possible. Another comparison of interest would be TCC
in modern linux headers, unnamed union is used, for example in bits/pthreadtypes.h:
unsigned int __nusers;
__extension__ union
{
int __spins;
__pthread_slist_t __list;
};
when this header is included, lcc will error out:
/usr/include/bits/pthreadtypes.h:99: field name missing
Please review the attached patch. The variable 'n' will never be negative so it is either pointless or an error to check if it is.
diff --git a/cpp/unix.c b/cpp/unix.c
index b3db364..400af35 100755
--- a/cpp/unix.c
+++ b/cpp/unix.c
@@ -97,7 +97,7 @@ memmove(void *dp, const void *sp, size_t n)
{
unsigned char *cdp, *csp;
- if (n<=0)
+ if (n==0)
return 0;
cdp = dp;
csp = (unsigned char *)sp;
Best regards and many thanks
Martin Ettl
HI dear author,
It's truly a honor to write a letter to you, I'm building your project nowadays and found the error when building as following, I wonder if there is a chance that you know the reason? :)
thank you
best regards to you
William
Thank you for LCC -- it has been a pleasure and an educational experience to work with.
The following code fails an assertion when compiled (as r.c
) with rcc -Wf-target=symbolic -target=sparc/sun -S r.c
:
void fails(void)
{
int a=0,b=0,c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,
k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;
a |= b|c|1|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t;
a |= b|c |d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t;
}
On my Macbook Pro :
$ cc --version
Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin14.1.0
Thread model: posix
$ mkdir -p build && cd build && make -C .. BUILDDIR=$PWD HOSTFILE=etc/solaris.c all
# ... build succeeds ... (as long as I #undef memmove inside cpp/unix.c to prevent clashing with system memmove)
$ ./rcc -Wf-target=symbolic -target=sparc/sun -S r.c
.global _fails
.seg "text"
Assertion failed: (bestreg), function spillee, file src/gen.c, line 686.
Abort trap: 6
In a Debian GNU/Linux VM :
$ cc --version
cc (Debian 4.9.1-19) 4.9.1
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ mkdir -p build && cd build && make -C .. BUILDDIR=$PWD HOSTFILE=etc/solaris.c all
# ... build succeeds ... (memmove issue does not occur)
$ ./rcc -Wf-target=symbolic -target=sparc/sun -S r.c
.global _fails
.seg "text"
rcc: src/gen.c:686: spillee: Assertion `bestreg' failed.
Aborted
I first noticed this on my own backend (lcc-tenyr) and then while trying to debug, found it does similarly on sparc. I am not gunning for sparc specifically to be mended, but I am wondering if there is a target-independent bug, given that this happens even with -Wf-target=symbolic
. This bug does not occur for me with -target=mips/irix
or -target=x86/linux
.
The problem seems to be that ralloc
runs out of viable registers to spill in spillee
. For my own architecture, this happens quite soon because the lastuse
pointer is never updated. I am wondering if lastuse
is not updated in enough cases ?
I have found your article in the internet where it says that you have added a cil backend.
Where is the code?
The below program will output 0.000000
for all 6 values.
#include <stdio.h>
typedef struct xy
{
double x, y;
} t_xy;
t_xy vec(double x, double y)
{
return ( (t_xy){x, y} );
}
t_xy operator+ (t_xy &a, t_xy &b)
{
return ( (t_xy){a.x + b.x, a.y + b.y} );
}
int main(int argc, char *argv[])
{
t_xy a = vec(1, 2);
t_xy b = vec(2, 4);
t_xy c = a + b;
printf("a == %f %f\n", a.x, a.y);
printf("b == %f %f\n", b.x, b.y);
printf("c == %f %f\n", c.x, c.y);
}
The same applies even to the simplest case:
t_xy test = (t_xy){1.0, 2.0};
printf("test == %f %f\n", test.x, test.y);
Other compilers allow for switching between C89 and C99 - for example, GCC. To maintain compilation compatibility with other programs, LCC should have a C99 mode as well.
Hello! :)
I just wanted to try this project out and made me a clone and attempted a build with mkdir out && make all BUILDDIR=./out
. This is what essentially happened:
cc -g -c -Icpp -o out/getopt.o cpp/getopt.c
cpp/getopt.c:21:3: warning: add explicit braces to avoid dangling else [-Wdangling-else]
else if (strcmp(argv[optind], "--") == 0) {
^
1 warning generated.
cc -g -c -Icpp -o out/unix.o cpp/unix.c
cpp/unix.c:96:1: error: expected parameter declarator
memmove(void *dp, const void *sp, size_t n)
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/secure/_string.h:69:47: note: expanded from macro 'memmove'
__builtin___memmove_chk (dest, __VA_ARGS__, __darwin_obsz0 (dest))
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/secure/_common.h:38:63: note: expanded from macro '__darwin_obsz0'
#define __darwin_obsz0(object) __builtin_object_size (object, 0)
^
cpp/unix.c:96:1: error: expected ')'
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/secure/_string.h:69:47: note: expanded from macro 'memmove'
__builtin___memmove_chk (dest, __VA_ARGS__, __darwin_obsz0 (dest))
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/secure/_common.h:38:63: note: expanded from macro '__darwin_obsz0'
#define __darwin_obsz0(object) __builtin_object_size (object, 0)
^
cpp/unix.c:96:1: note: to match this '('
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/secure/_string.h:69:47: note: expanded from macro 'memmove'
__builtin___memmove_chk (dest, __VA_ARGS__, __darwin_obsz0 (dest))
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/secure/_common.h:38:54: note: expanded from macro '__darwin_obsz0'
#define __darwin_obsz0(object) __builtin_object_size (object, 0)
^
cpp/unix.c:96:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
memmove(void *dp, const void *sp, size_t n)
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/secure/_string.h:69:47: note: expanded from macro 'memmove'
__builtin___memmove_chk (dest, __VA_ARGS__, __darwin_obsz0 (dest))
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/secure/_common.h:38:32: note: expanded from macro '__darwin_obsz0'
#define __darwin_obsz0(object) __builtin_object_size (object, 0)
^
cpp/unix.c:96:1: error: conflicting types for '__builtin___memmove_chk'
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/secure/_string.h:69:3: note: expanded from macro 'memmove'
__builtin___memmove_chk (dest, __VA_ARGS__, __darwin_obsz0 (dest))
^
cpp/unix.c:96:1: note: '__builtin___memmove_chk' is a builtin with type 'void *(void *, const void *, unsigned long, unsigned long)'
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/secure/_string.h:69:3: note: expanded from macro 'memmove'
__builtin___memmove_chk (dest, __VA_ARGS__, __darwin_obsz0 (dest))
^
cpp/unix.c:96:1: error: definition of builtin function '__builtin___memmove_chk'
memmove(void *dp, const void *sp, size_t n)
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/secure/_string.h:69:3: note: expanded from macro 'memmove'
__builtin___memmove_chk (dest, __VA_ARGS__, __darwin_obsz0 (dest))
^
1 warning and 4 errors generated.
make: *** [out/unix.o] Error 1
macOS uses a specialized version of LLVM Clang:
$ cc --version
Apple LLVM version 10.0.0 (clang-1000.11.45.5)
Target: x86_64-apple-darwin18.2.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
Kind regards,
Ingwie.
Please review the attached patch, it removes an unused variable in src/stmt.c
Best regards and many thanks
Martin Ettl
diff --git a/src/stmt.c b/src/stmt.c
index a591d42..2e2e916 100755
--- a/src/stmt.c
+++ b/src/stmt.c
@@ -38,7 +38,6 @@ Code code(int kind) {
return cp;
}
int reachable(int kind) {
- Code cp;
if (kind > Start) {
Code cp;
Please take a look at following assert statement from gen.c, line 827:
assert(p && p->sclass == REGISTER && p->sclass == REGISTER && p->x.regnode);
The statement p->sclass == REGISTER
appears twice, which looks like a copy&paste error to me.
Best regards and many thanks for taking a look at this issue.
Martin Ettl
Hi David,
I was wondering if you could share the history of the cpp C preprocessor. Was this written specifically for lcc?
Thanks and Regards
Dibyendu
The LCC preprocessor came from Plan9, which has recently been released under GPL. It would be nice to have the cleaned up and ANSI-C-fied preprocessor in LCC available under GPL as well.
http://www.theregister.co.uk/2014/02/14/plan_9_moves_to_gnu_space/
Could be possible to defined LCC to output version ?
Please review the attached patch, it simply removes an unused variable in etc/lcc.c.
Best regards and many thanks
Martin Ettl
diff --git a/etc/lcc.c b/etc/lcc.c
index 06880b7..95b621a 100755
--- a/etc/lcc.c
+++ b/etc/lcc.c
@@ -778,10 +778,9 @@ char *strsave(const char *str) {
char *stringf(const char *fmt, ...) {
char buf[1024];
va_list ap;
- int n;
va_start(ap, fmt);
- n = vsprintf(buf, fmt, ap);
+ (void)vsprintf(buf, fmt, ap);
va_end(ap);
return strsave(buf);
}
#define x 3
#define f(a) f(x * (a))
#undef x
#define x 2
#define g f
#define z z[0]
#define h g(~
#define m(a) a(w)
#define w 0,1
#define t(a) a
f(y+1) + f(f(z)) % t(t(g)(0) + t)(1);
g(x+(3,4)-w) | h 5) & m
(f)^m(m);
/* expected: */
/*
f(2 * (y+1)) + f(2 * (f(2 * (z[0])))) % f(2 * (0)) + t(1);
f(2 * (2+(3,4)-0,1)) | f(2 * (~ 5)) & f(2 * (0,1))^m(0,1);
*/
Reproducible with the preprocessor compiled with Open Watcom C/C++ 1.9, MinGW 4.8.2, my Smaller C and run on Windows 7 x64. Also reproducible with the preprocessor compiled with gcc 4.6.3 on Ubuntu 12.04LTS.
The declaration of main
:74 is missing a type entirely. I set this to int
and proceeded.
Trying to run make lcc
gives me an error about not having permission to write the .o
files, so I sudo
to give the process permission and proceeded.
Compilation then failed because /lburg/gram.c
uses free
but <stdlib.h>
hasn't been included and no definition is given for free
, so I include it at the top of the file and try to proceed again.
But at this stage, regardless of what C-compiler I try to build with (clang, gcc, tcc, chibicc, ...) I get variations of the same problem -- lots of files don't want to build because of implicit function use (which is possible to get past, but I still end up with missing output files, regardless) or because I'm missing .o
objects or whatever
# sudo make lcc CC=gcc
cc -g -c -o /host.o
cc: fatal error: no input files
compilation terminated.
make: *** [makefile:128: /host.o] Error 1
So okay, let's try just running each of the make commands on their own.
sudo make cpp
sudo make bprint
sudo make liblcc
sudo make lburg
sudo make rcc
make: Nothing to be done for 'cpp'.
make: Nothing to be done for 'bprint'.
make: Nothing to be done for 'liblcc'.
make: Nothing to be done for 'lburg'.
make: Nothing to be done for 'rcc'.
so those ones seem to work, but no matter what order I do the rest in, compilation fails, and the outputs generally look like
sudo make triple
cc -g -c -o /host.o
cc: fatal error: no input files
compilation terminated.
make: *** [makefile:128: /host.o] Error 1
How am I supposed to build this? because make all
doesn't work either
cpp/getopt.c:21:3: warning: add explicit braces to avoid dangling else [-Wdangling-else]
21 | else if (strcmp(argv[optind], "--") == 0) {
| ^
1 warning generated.
clang -g -c -Icpp -o /unix.o cpp/unix.c
clang -g -o /cpp /cpp.o /lexer.o /nlist.o /tokens.o /macro.o /eval.o /include.o /hideset.o /getopt.o /unix.o
clang -g -c -o /host.o
clang: error: no input files
make: *** [makefile:128: /host.o] Error 1
I can't build lcc under linux (Archlinux and Manjaro), I followed the tutorial:
https://htmlpreview.github.io/?https://raw.githubusercontent.com/drh/lcc/master/doc/install.html#rcc
And try to use this script : https://groups.google.com/g/comp.compilers.lcc/c/HJ5TeSuP3gY/m/jEiwz-J_dpoJ
i still have problems compiling a simple program, i tested under debian buster and alpine linux.
Under debian:
Step 12/25 : RUN lcc hello.c -target=x86/linux
---> Running in ed78d5579c39
cpp: /usr/include/stdio.h:27 hello.c:1 Could not find include file <bits/libc-header-start.h>
cpp: /usr/include/stdio.h:33 hello.c:1 Could not find include file <stddef.h>
cpp: /usr/include/stdio.h:38 hello.c:1 Could not find include file <bits/types.h>
cpp: /usr/include/stdio.h:39 hello.c:1 Could not find include file <bits/types/__fpos_t.h>
cpp: /usr/include/stdio.h:40 hello.c:1 Could not find include file <bits/types/__fpos64_t.h>
cpp: /usr/include/stdio.h:41 hello.c:1 Could not find include file <bits/types/__FILE.h>
cpp: /usr/include/stdio.h:42 hello.c:1 Could not find include file <bits/types/FILE.h>
cpp: /usr/include/stdio.h:43 hello.c:1 Could not find include file <bits/types/struct_FILE.h>
cpp: /usr/include/stdio.h:133 hello.c:1 Could not find include file <bits/stdio_lim.h>
cpp: /usr/include/stdio.h:290 hello.c:1 Syntax error in #if/#elsif
cpp: /usr/include/stdio.h:363 hello.c:1 Syntax error in #if/#elsif
cpp: /usr/include/stdio.h:405 hello.c:1 Syntax error in #if/#elsif
cpp: /usr/include/stdio.h:567 hello.c:1 Syntax error in #if/#elsif
cpp: /usr/include/stdio.h:592 hello.c:1 Syntax error in #if/#elsif
cpp: /usr/include/stdio.h:781 hello.c:1 Could not find include file <bits/sys_errlist.h>
The command '/bin/sh -c lcc hello.c -target=x86/linux' returned a non-zero code: 1
Under alpine linux:
Step 11/24 : RUN lcc hello.c
---> Running in 3f1e0f061c10
hello.c: /usr/include/bits/alltypes.h:326: syntax error; found `va_list' expecting `;'
The command '/bin/sh -c lcc hello.c' returned a non-zero code: 1
If you want to see Dockerfile : https://github.com/bensuperpc/docker-lcc/blob/main/Dockerfile
Please review the attached patch, which removes a duplicate statement in a for loop in file src/profio.c.
Probably this was a copy&paste issue.
Best regards and many thanks
Martin Ettl
diff --git a/src/profio.c b/src/profio.c
index 6cae414..87fc175 100755
--- a/src/profio.c
+++ b/src/profio.c
@@ -60,7 +60,7 @@ static void acaller(char *caller, char *file, int x, int y, in
q->y = y;
q->count = 0;
for (r = &callee->callers; *r && (strcmp(q->name, (*r)->name) >
- || strcmp(q->file, (*r)->file) > 0 || q->y > (*r)->y ||
+ || strcmp(q->file, (*r)->file) > 0 || q->y > (*r)->y); r
;
q->link = *r;
*r = q;
Building lcc on Windows is basically fubar. The instruction are way outdated.
outp
in cpp\cpp.c
clashes with the Windows function of the same name. Renaming it the something else makes the problem go away. (It is only used in the cpp
folder, from memory this includes :cpp.h
, cpp.c
, macro.c
, include.c
and maybe some other I forgot).libc.lib
no longer ships with Visual Studio. It should be replaced with libcmt.lib
in etc\win32.src
, which is apparently the multi-threaded version.make ... test
) described in the installation guide fails because the file limits.s
is generated nearly empty. The triple test (make ... triple
) hangs forever.I have not really investigated, but might it not be easier to base the Windows version on MinGW, as it is much closer to how the install works on Unix ?
Also, it would be great to offer precompiled binaries. It might at least be a temporary solution until the build system is fixed.
I'm getting error when compiling following code in ubuntu 10.04 LTS:
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
int main() {
struct stat b1, b2;
stat("/bin",&b1);
stat("/usr",&b2);
if(b1.st_dev == b2.st_dev) {
if(b1.st_ino == b2.st_ino) {
printf("/bin and /usr is same i-node\n");
}
}
return 0;
}
and I got
stattest.c:10: operands of == have illegal types `__rlim64_t' and `__rlim64_t'
which typedefs as __u_quad_t which is "long long"(64-bit integer) type:
bits/types.h:typedef unsigned long int __u_quad_t;
(i >> 0) = j;
After the simplify
at simp.c
, the expression 'i >> 0' will be simplified to 'i' which is an INDIR
tree, thus the assignment check will be OK.
The same problem can be found in other identity simplification.
do you havs a plan to support lcc run on macOS?
Hi there,
I have probably not done this correctly, but for some reason I'm trying to do a simple helloworld app and generate a linux x86 binary, unfortunately it's generating what appears to be assembly.
Following instructions from this site,
http://drh.github.io/lcc/current/doc/install.html
I've compiled both driver and compiler, and then created a simple hello world app, i.e.
int main()
{
printf("Hello World!");
return(0);
}
compiling with gcc works great, I run it and get the text printed on screen. But when I compile with lcc, using this command,
./rcc main.c -target=x86/linux -o helloworld
a file gets produced called helloworld, but it contains assembly code, for example,
.globl main
.text.align 16
.type main,@function
main:
...
Any ideas what I'm doing wrong?
Please review the attached patch. It simply removed a not needed allocation of a local buffer of 50 characters when the function vtoa() is called.
diff --git a/src/sym.c b/src/sym.c
index e4a6e30..00099f2 100755
--- a/src/sym.c
+++ b/src/sym.c
@@ -313,7 +313,6 @@ Symbol mksymbol(int sclass, const char *name, Type ty) {
/* vtoa - return string for the constant v of type ty */
char *vtoa(Type ty, Value v) {
- char buf[50];
ty = unqual(ty);
switch (ty->op) {
Best regards and many thanks
Martin Ettl
Hey we're having a discussion over at Atariage about the possibility of getting a C compiler to target the "CP1610" CPU. Ref: http://atariage.com/forums/topic/286670-sdcc-pic16-c-compiler/?p=4192163
Its a 16 bit CPU where sizeof(char) = sizeof(int) = sizeof(void*) = 1.
Is re-targeting for this CPU possible and if so are there any good docs or reference for what parts need to be changed in LCC to make this happen?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.