Logo54.162.10.211 
  Home  News  Recent  Forums  Search  Contact
  Menu
 Username

 Password


   Register here

 Main menu
   View images
   BBCode test
 
 Content
   Statement of intent
   Terms Of Service
   IRC Channel
   List Content

 In cooperation with
  OS4Depot.net
  OpenAmiga.org
  OS4Welt

 Links
  AmigaOS4
  IntuitionBase
  UtilityBase
  Amiga Flame
  Amiga Spirit
  AmiKit
  Aminet
  AmiBay
  AmigaBounty
  AmigaWorld
  Exec
  Amiga.cz
  View comments
Title  
  Forums
    Development
      AmigaOS 4  
samo79Compile issue20110313 01:21
I'm trying to compile LOLCODE on OS4 starting from the AROS port availible on archives.aros-exec and also directly from the original Justinmeza

http://archives.aros-exec.org/?function=showfile&file=development/language/lolcode.aros-i386-with-src.zip

But for some reason it didn't compile, this is the output i have:

3.AmigaOS4:> Work:SDK/Progetti/justinmeza-lci-bfe73bf/
3.Work:SDK/Progetti/justinmeza-lci-bfe73bf> make
gcc -O2 -c -o lexer.o lexer.c
gcc -O2 -c -o tokenizer.o tokenizer.c
gcc -O2 -c -o parser.o parser.c
gcc -O2 -c -o interpreter.o interpreter.c
interpreter.c: In function 'interpretInputStmtNode':
interpreter.c:2626: warning: comparison is always false due to limited range of data type
gcc -O2 -c -o unicode.o unicode.c
gcc -O2 -c -o main.o main.c
make: *** No rule to make target `-lm', needed by `lci'. Stop.
3.Work:SDK/Progetti/justinmeza-lci-bfe73bf>


And this is the Makefile file:

TARGET = lci
LIBS = -lm
OBJS = lexer.o tokenizer.o parser.o interpreter.o unicode.o main.o
SRCS = lexer.c tokenizer.c parser.c interpreter.c unicode.c main.c
INSTALL = cp
CPPFLAGS = -O2

prefix = /usr/local
bindir = $(prefix)/bin
testdir = ./test

all: $(TARGET)

$(TARGET): $(OBJS) $(LIBS)
$(CC) $(CPPFLAGS) -o $(TARGET) $(OBJS) $(LIBS)

pedantic: $(OBJS) $(LIBS)
$(CC) -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wundef -W -Wall -ansi -pedantic -g -o $(TARGET) $(OBJS) $(LIBS)

check: all
@cd $(testdir) && ./testDir.sh -q ../$(TARGET) 1.2-Tests/

check-mem: all
@echo "This will take a long time! Be patient!"
@cd $(testdir) && ./testDir.sh -q -m ../$(TARGET) 1.2-Tests/

install: all
$(INSTALL) $(TARGET) $(bindir)/$(TARGET)

TAGS: $(SRCS)
ctags $(SRCS)

docs: Doxyfile $(SRCS)
doxygen

clean:
-rm -f $(OBJS)
-rm -f $(TARGET)

distclean: clean
-rm -f tags
-rm -rf html


So I tryed also passing the TARGET name into the make command but it fails again.
The only thing i know talking with the original author is that i may need the math lib that must be linked with clib2 or similar, but i think that the real problem are Makefile related ..

Any tips ?
Navigate: 1-14 
TrevRe: Compile issue20110313 01:30  #2839
@samo79

Change:

$(TARGET): $(OBJS) $(LIBS)

to:

$(TARGET): $(OBJS)

and:

pedantic: $(OBJS) $(LIBS)

to:

pedantic: $(OBJS)

Both clib2 and newlib have a libm.a that should satisfy the linker.

Trev
tonywRe: Compile issue20110313 11:06  #2840
@samo79

What about the interpreter at line 2526?

It sounds as though the code is trying to compare a signed value with an unsigned one.

That sounds like a serious bug, but it ought to be easy to fix.
samo79Re: Compile issue20110313 18:04  #2845
First of all, thanks for you all for help :-)

@Trev

Ok changed as you suggested and now no more errors during compile :-)

This is the shell output after compile:

5.Work:SDK/Progetti/justinmeza-lci-bfe73bf> make
gcc -O2 -c -o lexer.o lexer.c
gcc -O2 -c -o tokenizer.o tokenizer.c
gcc -O2 -c -o parser.o parser.c
gcc -O2 -c -o interpreter.o interpreter.c
interpreter.c: In function 'interpretInputStmtNode':
interpreter.c:2626: warning: comparison is always false due to limited range of data type
gcc -O2 -c -o unicode.o unicode.c
gcc -O2 -c -o main.o main.c
gcc -O2 -o lci lexer.o tokenizer.o parser.o interpreter.o unicode.o main.o -lm
5.Work:SDK/Progetti/justinmeza-lci-bfe73bf>


But for what i've undestand it doesn't "link" the various files, now i have:

lexer.o
parser.o
unicode.o
tokanizer.o
interpreter.o
main.o
lci

How can i link them ? it is possible that problem was caused by the warning above into the interpreter.c ?

@tonyw

What about the interpreter at line 2526?

It sounds as though the code is trying to compare a signed value with an unsigned one.

That sounds like a serious bug, but it ought to be easy to fix.


Yep this is the "broken" line in interpreter.c that caused the warning:

if (c == EOF || c == 'r' || c == 'n') break;


And this is the entire function:

/** Interprets an input statement.
*
* pre a node was created by createStmtNode(StmtType type, void *stmt) where
* a type is ST_INPUT and a stmt was created by createInputStmtNode(IdentifierNode *).
* pre a scope was created by createScopeObject(ScopeObject *) and contains
* contents added by createScopeValue(ScopeObject *, IdentifierNode *) and
* contents updated by updateScopeValue(ScopeObject *, IdentifierNode *, ValueObject *).
*
* return A pointer to a ReturnObject structure with the default return value.
*
* retval NULL An error occurred during interpretation.
*
* see interpretCastStmtNode(StmtNode *, ScopeObject *)
* see interpretPrintStmtNode(StmtNode *, ScopeObject *)
* see interpretAssignmentStmtNode(StmtNode *, ScopeObject *)
* see interpretDeclarationStmtNode(StmtNode *, ScopeObject *)
* see interpretIfThenElseStmtNode(StmtNode *, ScopeObject *)
* see interpretSwitchStmtNode(StmtNode *, ScopeObject *)
* see interpretBreakStmtNode(StmtNode *, ScopeObject *)
* see interpretReturnStmtNode(StmtNode *, ScopeObject *)
* see interpretLoopStmtNode(StmtNode *, ScopeObject *)
* see interpretFuncDefStmtNode(StmtNode *, ScopeObject *)
* see interpretExprStmtNode(StmtNode *, ScopeObject *) */
ReturnObject *interpretInputStmtNode(StmtNode *node, /**< [in] A pointer to a StmtNode structure containing an InputStmtNode structure to interpret. */
ScopeObject *scope) /**< [in,out] A pointer to the ScopeObject structure to evaluate a node under. */
{
unsigned int size = 16;
unsigned int cur = 0;
char *temp = malloc(sizeof(char) * size);
char c;
void *mem = NULL;
InputStmtNode *stmt = (InputStmtNode *)node->stmt;
ValueObject *val = NULL;
while ((c = getchar())) {
/** note The specification is unclear as to the exact semantics
* of input. Here, we read up until the first newline or
* EOF but do not store it. */
if (c == EOF || c == 'r' || c == 'n') break;
if (cur > size - 1) {
/* Increasing buffer size. */
size *= 2;
mem = realloc(temp, sizeof(char) * size);
if (!mem) {
perror("realloc");
free(temp);
return NULL;
}
temp = mem;
}
temp[cur] = c;
cur++;
}
temp[cur] = '';
val = createStringValueObject(temp);
if (!val) {
free(temp);
return NULL;
}
if (!updateScopeValue(scope, stmt->target, val)) {
deleteValueObject(val);
return NULL;
}
return createReturnObject(RT_DEFAULT, NULL);
}
TrevRe: Compile issue20110313 18:11  #2846
@samo79

The last gcc command linked the objects into lci, which I assume is what you wanted.
samo79Re: Compile issue20110313 19:41  #2848
@Trev

Yes, but i'm not sure if i need to link also the other objects in order to make it fully functional :-)
TrevRe: Compile issue20110313 19:58  #2849
@samo79

Which other objects? Using gcc from the AmigaOS 4.x SDK, this line:

gcc -O2 -o lci lexer.o tokenizer.o parser.o interpreter.o unicode.o main.o -lm

means "link lexer.o, tokenizer.o, parser.o, interpreter.o, unicode.o, main.o, and libm.a into an executable named lci." You're not compiling anything, so '-02' is ignored. Do you have other required objects and libraries that aren't part of your makefile? If they were required for linking, linking would have failed.
TrevRe: Compile issue20110313 20:25  #2850
@samo79

Regarding the warning, the code assumes char is signed, and on GCC/PowerPC, I believe it's unsigned. You can add an option to CPPFLAGS in your makefile to force signed char:

CPPFLAGS = -O2 -fsigned-char

Comparisons to char values aren't usually portable. You might also be able to change the type of c to int, but I haven't looked over the code to see what the impact might be.

Edit: See http://www.network-theory.co.uk/docs/gccintro/gccintro_71.html for a discussion on the portability of signed and unsigned types.
samo79Re: Compile issue20110314 18:47  #2863
@Trev

means "link lexer.o, tokenizer.o, parser.o, interpreter.o, unicode.o, main.o, and libm.a into an executable named lci."


Ok thanks for your explain, i didn't know exactly how it works a makefile

You're not compiling anything, so '-02' is ignored. Do you have other required objects and libraries that aren't part of your makefile? If they were required for linking, linking would have failed.


No forget, i don't have any other object to link :-)
My confusion start when, (after the compile) i see all that "strange" objects in the folder, so once they are correctly linked i presume thay they are useless and i can erase all of them... (?)

Regarding the warning, the code assumes char is signed, and on GCC/PowerPC, I believe it's unsigned. You can add an option to CPPFLAGS in your makefile to force signed char:

CPPFLAGS = -O2 -fsigned-char


That's perfect now, no more warning and all files are linked :-)

Comparisons to char values aren't usually portable. You might also be able to change the type of c to int, but I haven't looked over the code to see what the impact might be.

Edit: See http://www.network-theory.co.uk/docs/gccintro/gccintro_71.html for a discussion on the portability of signed and unsigned types.


We we'll see if it works or not, i packed what i have and i'm going to upload a WIP version on OS4Depot now, meanwhile i'll check your link :-)

Again thanks a lot for your help !
TrevRe: Compile issue20110314 21:34  #2870
@samo79

You can erase the object files if you don't need tgem; however, the make system is intelligent enough to only regenerate a file if one of its dependencies has changed. If you modify lexer.c, for example, only lexer.o and lci must be regenerated.
samo79Re: Compile issue20110314 21:59  #2872
@Trev

Ok, here LOLEcode for OS4 if someone would like to try:

http://os4depot.net/?function=showfile&file=development/language/lolcode.lha
TrevRe: Compile issue20110315 00:47  #2876
@samo79

LOLCODE is cute, but is anyone actually using it to do real stuff? Also, lci is GPL, so you need to update your archive with an appropriate copyright notice (see README in the source archive) and make your source modifications available, either directly or through a written offer. It's probably easiest to just include a copy of your source in the archive. :-) If the original author granted you a different license, you can ignore this.
samo79Re: Compile issue20110315 15:10  #2893
@Trev

Also, lci is GPL, so you need to update your archive with an appropriate copyright notice (see README in the source archive) and make your source modifications available,


You are right about licence, i forgot to include one so i will add it now :-)
About the program itself I didn't touch anythings on source level (there are only that few modifications you suggest me for the Makefile in order to compile it on OS4), also the entire source is already included into the archive, it miss only this simple GPL licence i think :-)
TrevRe: Compile issue20110315 15:23  #2894
@samo79

The makefile is part of the source...
samo79Re: Compile issue20110317 09:13  #2928
@Trev

Done, i release it with a GPL licence text file inside :-)
Navigate: 1-14 
Home
Snack! forum website engine, Created in 2008 by Björn Hagström