svhawkins / B-Minor-Compiler

COMP 4060 B-Minor Compiler
2 stars 0 forks source link

add -fcommon to compiler flags #15

Closed FrankBau closed 5 months ago

FrankBau commented 7 months ago

for newer versions of gcc/clang you have to add -fcommon to CFLAGS in Makefile. Otherwise you get link errors like:

/usr/bin/ld: source/parser.o:(.bss+0x14): multiple definition of `yydebug'; source/parse.o:(.bss+0x0): first defined here
/usr/bin/ld: source/parser.o:(.bss+0x40): multiple definition of `error_text'; source/scanner.o:(.bss+0x0): first defined here
/usr/bin/ld: source/decl.o:(.bss+0x4): multiple definition of `global_error_count'; source/parser.o:(.bss+0x144): first defined here
/usr/bin/ld: source/decl.o:(.bss+0x0): multiple definition of `error_status'; source/parser.o:(.bss+0x140): first defined here
/usr/bin/ld: source/expr.o:(.bss+0x4): multiple definition of `global_error_count'; source/parser.o:(.bss+0x144): first defined here
/usr/bin/ld: source/expr.o:(.bss+0x0): multiple definition of `error_status'; source/parser.o:(.bss+0x140): first defined here
/usr/bin/ld: source/param_list.o:(.bss+0x0): multiple definition of `error_status'; source/parser.o:(.bss+0x140): first defined here
/usr/bin/ld: source/param_list.o:(.bss+0x4): multiple definition of `global_error_count'; source/parser.o:(.bss+0x144): first defined here
/usr/bin/ld: source/stmt.o:(.bss+0x4): multiple definition of `global_error_count'; source/parser.o:(.bss+0x144): first defined here
/usr/bin/ld: source/stmt.o:(.bss+0x0): multiple definition of `error_status'; source/parser.o:(.bss+0x140): first defined here
/usr/bin/ld: source/symbol.o:(.bss+0x0): multiple definition of `error_status'; source/parser.o:(.bss+0x140): first defined here
/usr/bin/ld: source/symbol.o:(.bss+0x4): multiple definition of `global_error_count'; source/parser.o:(.bss+0x144): first defined here
/usr/bin/ld: source/type.o:(.bss+0x0): multiple definition of `error_status'; source/parser.o:(.bss+0x140): first defined here
/usr/bin/ld: source/type.o:(.bss+0x4): multiple definition of `global_error_count'; source/parser.o:(.bss+0x144): first defined here
/usr/bin/ld: source/symbol_table.o:(.bss+0x4): multiple definition of `global_error_count'; source/parser.o:(.bss+0x144): first defined here
/usr/bin/ld: source/symbol_table.o:(.bss+0x0): multiple definition of `error_status'; source/parser.o:(.bss+0x140): first defined here

because you are defining those variables in header files. BTW Nice project, do you plan to work on it?

svhawkins commented 7 months ago

Nice for pointing that out! My current gcc version is 9.3.0 for Ubuntu. It's from 2019, so definitely outdated. This project is still a work in progress, yes. It was originally only needed for a semester-long course last year, though I thought it fun to continue on with it. This is the branch I'm currently developing on.

svhawkins commented 5 months ago

Resolved with commit https://github.com/svhawkins/B-Minor-Compiler/commit/5c716e80be85ab4812979d3d61a5a677b57a1c7e