Issues in fbc-0.90.0

For other topics related to the FreeBASIC project or its community.
TJF
Posts: 3468
Joined: Dec 06, 2009 22:27
Location: N47°, E15°

Issues in fbc-0.90.0

Postby TJF » Jul 01, 2013 12:25

I tried to compile fbc-0.90.0 with option -gen gcc.

Based on the fbc-0.90.0 source tree and the fbc-0.90.0 compiler (official LINUX release build with -gen gas) I applied these changes to makefile:

    A) adding -gen gcc

    Code: Select all

    ALLFBCFLAGS := -e -m fbc -w pedantic -gen gcc


    and B) changing the compiling order (to get the self compiled rtlib)

    Code: Select all

    .PHONY: all
    all: rtlib compiler gfxlib2

Then I exeuted make and got an fbc binary, which works pretty well, exept the following: Code like

Code: Select all

  WITH PEEK(UserUDT, ctx)
    IF 0 = LEN(.TypC) THEN ' try to fix it (may be faulty)
    ' ...
  END WITH


throughs

test.bas(87) error 247: Symbol not a CLASS, ENUM, TYPE or UNION type, before 'TypC' in 'if 0 = len(.TypC) then ' try to fix it (may be faulty)'


allthough .TypC is a legal member in UserUDT (code works well under fbc-0.24). It seems there is an issue with the LEN function.

But overall I've the feeling that the -gen gcc option needs just a little improvement to be used to compile itself.

Edit:
I just found out that the official version (-gen gas) also throughs this error message. So this seems to be not relateted to -gen gcc, but is an generall issue instead.

Version# corrected.
Last edited by TJF on Jul 02, 2013 9:45, edited 2 times in total.
dkl
Site Admin
Posts: 3206
Joined: Jul 28, 2005 14:45
Location: Germany

Re: Using -gen gcc to compile fbc

Postby dkl » Jul 01, 2013 12:57

Can you post a complete example that triggers the problem? In my attempt I cannot reproduce it:

Code: Select all

type userudt
   typc as string
end type

dim ctx as userudt ptr

with peek(userudt, ctx)
   if 0 = len(.typc) then
   ' ...
   end if
end with


By the way, you can also put this line:
config.mk wrote:FBFLAGS := -gen gcc


into a text file called "config.mk" next the FB makefile, and it should always use -gen gcc from then on. That way you don't have to modify the makefile itself.

Building the rtlib before the compiler only makes a difference if you're using fbc from the same tree to rebuild itself. In this case its only safe to build the rtlib before the compiler if they're the same version already, otherwise code generated by the old compiler won't match the new rtlib.

When using another host fbc to build the new compiler, it will always use its own rtlib (e.g. /usr/local/bin/fbc -> /usr/local/lib/freebasic/libfb.a), unless of course you're doing something like -p lib/freebasic/ to add the compiled rtlib from the build tree to the host fbc's set of library search directories.
TJF
Posts: 3468
Joined: Dec 06, 2009 22:27
Location: N47°, E15°

Re: Using -gen gcc to compile fbc

Postby TJF » Jul 01, 2013 13:11

Here you are

Code: Select all

TYPE UserUDT
  AS STRING TypC
END TYPE

FUNCTION fb_type(BYVAL ctx AS ANY PTR) AS STRING
  WITH PEEK(UserUDT, ctx)
    IF 0 = LEN(.TypC) THEN
    END IF
    RETURN ""
  END WITH
END FUNCTION


test.bas(7) error 247: Symbol not a CLASS, ENUM, TYPE or UNION type, before 'TypC' in 'IF 0 = LEN(.TypC) THEN'
dkl
Site Admin
Posts: 3206
Joined: Jul 28, 2005 14:45
Location: Germany

Re: Using -gen gcc to compile fbc

Postby dkl » Jul 01, 2013 16:21

It seems like it's a regression in 0.90, showing up since 8b428f8e, however the real problem was somewhere else, and it should be fixed now with 26539a6d.
TJF
Posts: 3468
Joined: Dec 06, 2009 22:27
Location: N47°, E15°

Re: Using -gen gcc to compile fbc

Postby TJF » Jul 01, 2013 17:31

Yep, better now. But sorry, not perfect.

When I compile fb-doc with fbc-0.9 I get a similar error message on this code (compiles under fbc-0.24)

Code: Select all

SUB doxy_emitBlockNames(BYVAL P AS Parser PTR)
  WITH *P
    SELECT CASE AS CONST *.Tk1
    CASE .TOK_PRIV, .TOK_PROT ': .UserInt = 0 ' !!! ToDo: hide private?
    CASE .TOK_PUBL            ': .UserInt = 1
    CASE .TOK_CLAS, .TOK_TYPE, .TOK_UNIO
      .parseBlockTyUn(@doxy_emitBlockNames)
    CASE .TOK_ENUM

'' ***** this line errors *****
      .parseBlockEnum(IIF(LEN(.BlockNam), @null_emitter, @doxy_emitBlockNames))

    CASE ELSE : IF 0 = .NamTok THEN EXIT SUB
      .Code &= NL & "\var " & .BlockNam & "::" & .SubStr(.NamTok) &  " " & FIXME & _
               NL & "\brief " & FIXME
    END SELECT
  END WITH
END SUB


src/fb-doc_emit_doxy.bas(138) error 24: Invalid data types, before ')' in .parseBlockEnum(IIF(LEN(.BlockNam), @null_emitter, @doxy_emitBlockNames))'


BTW:
When I comment this line the program compiles with -gen gas, but doesn't compile with -gen gcc.

src$ fbc-0.9 fb-doc.bas
src$ fbc-0.9 -gen gcc fb-doc.bas
fb-doc.c:250:6: Fehler: In Konflikt stehende Typen für »NULL_EMITTER«
fb-doc.c:155:6: Anmerkung: Vorherige Deklaration von »NULL_EMITTER« war hier
fb-doc.c: In Funktion »TOKTEST«:
fb-doc.c:454:67: Warnung: Trigraph ??- ignoriert, -trigraphs zum Aktivieren verwenden [-Wtrigraphs]
fb-doc.c: In Funktion »_ZN6PARSER4ERRRER8FBSTRING«:
fb-doc.c:2957:101: Warnung: Trigraph ??) ignoriert, -trigraphs zum Aktivieren verwenden [-Wtrigraphs]
fb-doc.c: In Funktion »_ZN6PARSER8TOKENIZEENS_8EOS_MODIE«:
fb-doc.c:3883:16: Warnung: Variable »CURRTOK$1« gesetzt, aber nicht verwendet [-Wunused-but-set-variable]
fb-doc.c: In Funktion »C_BLOCK«:
fb-doc.c:9231:103: Warnung: Trigraph ??- ignoriert, -trigraphs zum Aktivieren verwenden [-Wtrigraphs]
fb-doc.c: In Funktion »GTK_EMITBLOCKNAMES«:
fb-doc.c:9735:4: Warnung: Übergabe des Arguments 2 von »_ZN6PARSER14PARSEBLOCKTYUNEPFvPS_E« von inkompatiblem Zeigertyp [standardmäßig aktiviert]
fb-doc.c:1649:6: Anmerkung: »tmp$3« erwartet, aber Argument hat Typ »void (*)(void *)«
fb-doc.c:9740:4: Warnung: Übergabe des Arguments 2 von »_ZN6PARSER14PARSEBLOCKENUMEPFvPS_E« von inkompatiblem Zeigertyp [standardmäßig aktiviert]
fb-doc.c:1579:6: Anmerkung: »tmp$3« erwartet, aber Argument hat Typ »void (*)(void *)«
src$
dkl
Site Admin
Posts: 3206
Joined: Jul 28, 2005 14:45
Location: Germany

Re: Using -gen gcc to compile fbc

Postby dkl » Jul 01, 2013 18:20

The "invalid types" error seems to come from iif() which apparently doesn't accept function pointers at all. Simplified example:

Code: Select all

declare sub f1( )
declare sub f2( )
dim i as integer
print iif( i, @f1, @f2 )


It should be possible to fix it though. Besides that, I'm also seeing the -gen gcc error.

(which code were you testing exactly? I downloaded the fb-doc-0.2.7z, but the included doxy_emitBlockNames() function was different than the one you posted above. However I inserted the line containing iif() that you pointed out and that was enough to reproduce the error)
TJF
Posts: 3468
Joined: Dec 06, 2009 22:27
Location: N47°, E15°

Re: Using -gen gcc to compile fbc

Postby TJF » Jul 01, 2013 18:38

dkl wrote:(which code were you testing exactly? I downloaded the fb-doc-0.2.7z, but the included doxy_emitBlockNames() function was different than the one you posted above. However I inserted the line containing iif() that you pointed out and that was enough to reproduce the error)

Sorry, I don't know. (I'm sitting on my daughters netbook in the Garden. It's any pre-version.)

Would be nice to get it fixed. (IIF with SUB PTRs worked well in fbc-0.24.)

dkl wrote:Besides that, I'm also seeing the -gen gcc error.

I've some more stuff like this ...
TJF
Posts: 3468
Joined: Dec 06, 2009 22:27
Location: N47°, E15°

Re: Issues in fbc-0.90.0

Postby TJF » Jul 02, 2013 9:26

An fbc-0.9, build with option -gen gcc, segfaults when using option -gen gcc:

a$ fbc09 b.bas
a$ fbc09 -gen gcc b.bas
Speicherzugriffsfehler (Speicherabzug geschrieben)
a$ fbc09 -r -gen gcc b.bas
a$

Just generating the code works (option -r). (Tested on Ubuntu12.04)
nobozoz
Posts: 238
Joined: Nov 17, 2005 6:24
Location: Chino Hills, CA, USA

Re: Issues in fbc-0.90.0

Postby nobozoz » Jul 07, 2013 0:19

A new issue with fb.90 has emerged: include file "strmif.bi" is included in the fb.90 package, but unfortunately, "libstrmiids.dll.a" is not included.

This oversight breaks both ".\examples\win32\COM\MoviePlayer\test.bas" and "FBGUI library for windows 2" for sure.

Jim
Coolman
Posts: 206
Joined: Nov 05, 2010 15:09

Re: Issues in fbc-0.90.0

Postby Coolman » Jul 07, 2013 14:36

It is for this reason that you should always keep the old version of freebasic pending stabilization. said that in this specific case just copy libstrmiids.dll.a in the new version and it works. I note also appears that the size of exes increased by about 30% with the new version of freebasic ...
dkl
Site Admin
Posts: 3206
Joined: Jul 28, 2005 14:45
Location: Germany

Re: Issues in fbc-0.90.0

Postby dkl » Jul 18, 2013 19:22

Follow up on the IIF() + procedure pointer issue: I believe it is fixed in 0.90.1, by the same fix which fixed that C backend issue with procedure pointers and BYREF parameters.

By the way, libstrmiids.dll.a is included in 0.90.1 again, no idea why I missed it during 0.90.0. But copying from another FB version (or MinGW installation) should work just as well.

Return to “Community Discussion”

Who is online

Users browsing this forum: No registered users and 2 guests