ibara / m4

Portable OpenBSD m4.
https://devio.us/~bcallah/m4/
18 stars 2 forks source link

Linker error when building on Linux #2

Open Ella-0 opened 4 years ago

Ella-0 commented 4 years ago

I get a linker error when building on Linux.

~/m4 $ bmake
cc -DEXTENDED -I. -w -D_GNU_SOURCE  -c eval.c
cc -DEXTENDED -I. -w -D_GNU_SOURCE  -c expr.c
cc -DEXTENDED -I. -w -D_GNU_SOURCE  -c look.c
cc -DEXTENDED -I. -w -D_GNU_SOURCE  -c main.c
cc -DEXTENDED -I. -w -D_GNU_SOURCE  -c misc.c
cc -DEXTENDED -I. -w -D_GNU_SOURCE  -c gnum4.c
cc -DEXTENDED -I. -w -D_GNU_SOURCE  -c trace.c
yacc -d parser.y && mv y.tab.c parser.c && mv y.tab.h parser.h
lex  tokenizer.l
cc -DEXTENDED -I. -w -D_GNU_SOURCE  -c -o tokenizer.o lex.yy.c
rm -f lex.yy.c
cc -DEXTENDED -I. -w -D_GNU_SOURCE  -c parser.c
cc -DEXTENDED -I. -w -D_GNU_SOURCE  -c ohash.c
cc -DEXTENDED -I. -w -D_GNU_SOURCE  -c reallocarray.c
cc -DEXTENDED -I. -w -D_GNU_SOURCE  -c strlcpy.c
cc -DEXTENDED -I. -w -D_GNU_SOURCE  -c strtonum.c
cc  -o om4 eval.o expr.o look.o main.o misc.o gnum4.o trace.o tokenizer.o  parser.o ohash.o reallocarray.o strlcpy.o strtonum.o -lm
ld.lld: error: undefined symbol: yy_scan_string
>>> referenced by expr.c
>>>               expr.o:(expr)
clang-10: error: linker command failed with exit code 1 (use -v to see invocation)
*** Error code 1

Stop.
bmake: stopped in /home/user/m4
ibara commented 4 years ago

This is not a complete bug report. And I cannot reproduce this on either Debian 10.5 or the latest Termux. So help me help you. What distro are you using? What is your libc? What yacc are you using to build? What version of lex are you using?

A quick googling suggests that this is a bug in flex.

Ella-0 commented 4 years ago

I'm using my own distro, I'm using musl libc, byacc and sabotage-linux lex which is based off heirloom lex.

Ella-0 commented 4 years ago

And yes I do think lex is the issue. It built fine in the baseutils tree.

Ella-0 commented 3 years ago

Right I've finally gotten around to fixing this (kinda), I made the following really hacky patch to allow me to build this without flex so I can build flex with this. This is by no means the quality required to be merged but I think it's useful to have it here for people who try to do a similar thing to me.

--- om4-6.7/expr.c
+++ om4-6.7.old/expr.c
@@ -23,7 +23,18 @@
 int32_t end_result;
 const char *copy_toeval;

-extern void yy_scan_string(const char *);
+extern void yylex();
+extern FILE *yyin;
+
+void yy_scan_string(const char *str) {
+   yyin = fopen("/tmp/yyin", "rw");
+   fputs(str, yyin);
+   fclose(yyin);
+   yyin = fopen("/tmp/yyin", "ro");
+   yylex();
+   fclose(yyin)
+}
+
 extern int yyparse(void);

 int

My deepest apologies for the way I created this issue it was not very professional of me and sorry for leaving this open for so long.