FreeBASIC broken following OS upgrade; generates problematic .asm files...?

Linux specific questions.
bixbyru
Posts: 6
Joined: Mar 13, 2023 1:08

FreeBASIC broken following OS upgrade; generates problematic .asm files...?

Post by bixbyru »

Hey all -

I recently performed a distribution upgrade to my desktop's OS (OpenSuSE Leap, now 15.5 w/kernel 5.14.21-150500.55.36 SMP) and now I get the following when compiling anything more complex than Hello World:

Code: Select all

bixbyru@hofstra:~/BUILD/Tablet> fbc tablet.bas 
fbc: Symbol `ospeed' has different size in shared object, consider re-linking
tablet.asm: Assembler messages:
tablet.asm:1361: Error: operand size mismatch for `push'
tablet.asm:1414: Error: operand size mismatch for `push'
tablet.asm:1458: Error: operand size mismatch for `push'
bixbyru@hofstra:~/BUILD/Tablet> 
The terminfo warning doesn't bother me, but the .bas -> .c -> .asm part appears to be borked; this happens when I try to make FB from source as well, so it's not my code that's the problem. Also tried this on my Toughbook CF-31 (also x86-64) and no joy there, either.

Since this happens after the BASIC syntax check and initial compilation have completed successfully and the .c intermediate file has been created, I'll be all presumptious and blame the FB libraries or the C code generated by fbc; since GCC works just dandily when building a kernel, I believe the C compiler to be O.K.

I have NO idea whether this is due to FB calling a system app (something akin to p2c?) or library which has changed, something which the upgrade removed (it also zorched gtk.glade and some other stuff, but that I have fixed) a new (and less forgiving) assembler or what; kinda at a loss here, as this shiny black box isn't giving me much to go on.

Help...?
shadow008
Posts: 86
Joined: Nov 26, 2013 2:43

Re: FreeBASIC broken following OS upgrade; generates problematic .asm files...?

Post by shadow008 »

I hate to ask something so basic (pun very much intended) but did you compile with -gen gcc? I only ask because your example snippet suggests you didn't. If not, fbc defaults to -gen gas (I think) so your bug is likely in the gas64 emmiter. You'll want to check that thread out and post your bug there. viewtopic.php?t=27478
bixbyru
Posts: 6
Joined: Mar 13, 2023 1:08

Re: FreeBASIC broken following OS upgrade; generates problematic .asm files...?

Post by bixbyru »

Well, tomorrow I'll certainly make sure o' that.

Thanks!
SARG
Posts: 1768
Joined: May 27, 2005 7:15
Location: FRANCE

Re: FreeBASIC broken following OS upgrade; generates problematic .asm files...?

Post by SARG »

Hi,
Unlike fbc32bit with fbc64bit the default backend is, at least for now, gcc not gas64.
Whatever the case show your code or a snippet causing the issue, the easiest to help you
angros47
Posts: 2326
Joined: Jun 21, 2005 19:04

Re: FreeBASIC broken following OS upgrade; generates problematic .asm files...?

Post by angros47 »

I would also try recompiling the runtime libraries
shadow008
Posts: 86
Joined: Nov 26, 2013 2:43

Re: FreeBASIC broken following OS upgrade; generates problematic .asm files...?

Post by shadow008 »

SARG wrote: Nov 14, 2023 9:20 Hi,
Unlike fbc32bit with fbc64bit the default backend is, at least for now, gcc not gas64.
The more you know. The wiki isn't clear about 64 bit unfortunately.
fxm
Moderator
Posts: 12132
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: FreeBASIC broken following OS upgrade; generates problematic .asm files...?

Post by fxm »

shadow008 wrote: Nov 14, 2023 18:09 The more you know. The wiki isn't clear about 64 bit unfortunately.
Wiki updated:
CompilerOptgen → fxm [added the default values]
marcov
Posts: 3462
Joined: Jun 16, 2005 9:45
Location: Netherlands
Contact:

Re: FreeBASIC broken following OS upgrade; generates problematic .asm files...?

Post by marcov »

bixbyru wrote: Nov 13, 2023 21:43 tablet.asm:1361: Error: operand size mismatch for `push'
Sounds like Intel assembler syntax being interpreted by an assembler expecting AT&T.
bixbyru
Posts: 6
Joined: Mar 13, 2023 1:08

Re: FreeBASIC broken following OS upgrade; generates problematic .asm files...?

Post by bixbyru »

shadow008 wrote: Nov 14, 2023 1:01 I hate to ask something so basic (pun very much intended) but did you compile with -gen gcc? I only ask because your example snippet suggests you didn't. If not, fbc defaults to -gen gas (I think) so your bug is likely in the gas64 emmiter. You'll want to check that thread out and post your bug there. viewtopic.php?t=27478
Well, specifying gas64 made it work; the default was -gen gcc. It never occurred to change the assembler, because fbc emits C code and typically C "just works."

It still whines about aspects of the .obj file, but it works.
robert
Posts: 169
Joined: Aug 06, 2019 18:45

Re: FreeBASIC broken following OS upgrade; generates problematic .asm files...?

Post by robert »

Like @bixbyru, I'm running OpenSUSE.

TumbleWeed in Windows 11 WSL.

I installed FreeBASIC-1.10.1-linux-x86_64 then cloned the freebasic/fbc github repo and tried to make.

Make quit not too far in, here

Code: Select all

FBC src/compiler/obj/linux-x86_64/ast-node-branch.o
fbc: Symbol `ospeed' has different size in shared object, consider re-linking
src/compiler/obj/linux-x86_64/ast-node-branch.asm: Assembler messages:
src/compiler/obj/linux-x86_64/ast-node-branch.asm:327: Error: operand size mismatch for `push'
make: *** [makefile:785: src/compiler/obj/linux-x86_64/ast-node-branch.o] Error 1
I changed the makefile from

Code: Select all

FBC := fbc
to

Code: Select all

FBC := fbc -gen gas64 
and make completed successfully and installed without a problem.
SARG
Posts: 1768
Joined: May 27, 2005 7:15
Location: FRANCE

Re: FreeBASIC broken following OS upgrade; generates problematic .asm files...?

Post by SARG »

Add these option -RR -R (without -gen gas64) so the asm code will not be removed and we can see what it looks like.
The file (ast-node-branch.asm) should be in same folder as the source code.

Code: Select all

FBC := fbc -RR -R 
mandian
Posts: 6
Joined: Mar 09, 2024 13:06

Re: FreeBASIC broken following OS upgrade; generates problematic .asm files...?

Post by mandian »

Hi,

I'm trying to build FreeBASIC on OpenMandriva and I got the same issue. Here is the content of my ast-node-branch.asm.

https://pastebin.com/rWZ8fkMZ
SARG
Posts: 1768
Joined: May 27, 2005 7:15
Location: FRANCE

Re: FreeBASIC broken following OS upgrade; generates problematic .asm files...?

Post by SARG »

Hi,

I get the file but can you show the error message with the line number.
mandian
Posts: 6
Joined: Mar 09, 2024 13:06

Re: FreeBASIC broken following OS upgrade; generates problematic .asm files...?

Post by mandian »

Hi @SARG,

here is the relevant part. The C compiler is gcc 13.1.1 (clang doesn't work).

Code: Select all

cp bootstrap/fbc bin/fbc
+ /usr/bin/make -O -j2 V=1 VERBOSE=1 clean-compiler
rm -rf bin/fbc src/compiler/obj/linux-x86_64
rmdir bin
+ /usr/bin/make -O -j2 V=1 VERBOSE=1 compiler FBC=./bootstrap/fbc 'FBFLAGS= -i inc -g' 'FBCFLAGS= -maxerr 1 -w all -g  -RR -R' CC=gcc 'CFLAGS= -std=gnu89'
mkdir -p src/compiler/obj/linux-x86_64
mkdir -p bin
./bootstrap/fbc -e -m fbc -w pedantic -d ENABLE_LIB64 -maxerr 1 -w all -g  -RR -R -i inc -g -c src/compiler/ast-gosub.bas -o src/compiler/obj/linux-x86_64/ast-gosub.o
./bootstrap/fbc -e -m fbc -w pedantic -d ENABLE_LIB64 -maxerr 1 -w all -g  -RR -R -i inc -g -c src/compiler/ast-helper.bas -o src/compiler/obj/linux-x86_64/ast-helper.o
./bootstrap/fbc -e -m fbc -w pedantic -d ENABLE_LIB64 -maxerr 1 -w all -g  -RR -R -i inc -g -c src/compiler/ast-node-addr.bas -o src/compiler/obj/linux-x86_64/ast-node-addr.o
./bootstrap/fbc -e -m fbc -w pedantic -d ENABLE_LIB64 -maxerr 1 -w all -g  -RR -R -i inc -g -c src/compiler/ast-misc.bas -o src/compiler/obj/linux-x86_64/ast-misc.o
./bootstrap/fbc -e -m fbc -w pedantic -d ENABLE_LIB64 -maxerr 1 -w all -g  -RR -R -i inc -g -c src/compiler/ast-node-arg.bas -o src/compiler/obj/linux-x86_64/ast-node-arg.o
./bootstrap/fbc -e -m fbc -w pedantic -d ENABLE_LIB64 -maxerr 1 -w all -g  -RR -R -i inc -g -c src/compiler/ast-node-assign.bas -o src/compiler/obj/linux-x86_64/ast-node-assign.o
./bootstrap/fbc -e -m fbc -w pedantic -d ENABLE_LIB64 -maxerr 1 -w all -g  -RR -R -i inc -g -c src/compiler/ast-node-branch.bas -o src/compiler/obj/linux-x86_64/ast-node-branch.o
src/compiler/obj/linux-x86_64/ast-node-branch.asm: Assembler messages:
src/compiler/obj/linux-x86_64/ast-node-branch.asm:517: Error: operand size mismatch for `push'
make: *** [makefile:740: src/compiler/obj/linux-x86_64/ast-node-branch.o] Error 1
make: *** Waiting for unfinished jobs....
./bootstrap/fbc -e -m fbc -w pedantic -d ENABLE_LIB64 -maxerr 1 -w all -g  -RR -R -i inc -g -c src/compiler/ast-node-bop.bas -o src/compiler/obj/linux-x86_64/ast-node-bop.o
coderJeff
Site Admin
Posts: 4326
Joined: Nov 04, 2005 14:23
Location: Ontario, Canada
Contact:

Re: FreeBASIC broken following OS upgrade; generates problematic .asm files...?

Post by coderJeff »

mandian wrote: Mar 09, 2024 15:42 here is the relevant part. The C compiler is gcc 13.1.1 (clang doesn't work).
What version is the fbc bootstrap compiler?

Normally I would not copy over the bootstrap compiler to ./bin, but maybe I don't understand what steps you are following or what script this is from. ... nevermind, I looked more carefully.

Seems like there is a bug on gcc and/or binutils side.

Seen this too in clang and the workaround was to use at&t assembly generation.

Try passing command line option '-asm att' to fbc. This will tell fbc to tell gcc to emit AT&T assembler syntax.
Post Reply