m4 icon indicating copy to clipboard operation
m4 copied to clipboard

Linker error when building on Linux

Open Ella-0 opened this issue 5 years ago • 4 comments

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

Ella-0 avatar Aug 12 '20 14:08 Ella-0

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.

ibara avatar Aug 12 '20 14:08 ibara

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

Ella-0 avatar Aug 12 '20 14:08 Ella-0

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

Ella-0 avatar Aug 12 '20 14:08 Ella-0

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.

Ella-0 avatar Feb 03 '21 21:02 Ella-0