Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with last few commits. #5

Closed
Inesgor opened this issue Jun 20, 2021 · 2 comments
Closed

Problem with last few commits. #5

Inesgor opened this issue Jun 20, 2021 · 2 comments

Comments

@Inesgor
Copy link

Inesgor commented Jun 20, 2021

Hi. Thank you for the work you are doing.
There seems to be an issue with the last few commits.
This commit onwards, doing sudo make install throws an error, which isn't so in the previous commits.

Here is the output:

$ sudo make clean install 
rm -f *.o vi
cc -c -pedantic -Wall -Wfatal-errors -std=c99 -D_POSIX_C_SOURCE=200809L   vi.c
cc -c -pedantic -Wall -Wfatal-errors -std=c99 -D_POSIX_C_SOURCE=200809L   ex.c
cc -c -pedantic -Wall -Wfatal-errors -std=c99 -D_POSIX_C_SOURCE=200809L   lbuf.c
cc -c -pedantic -Wall -Wfatal-errors -std=c99 -D_POSIX_C_SOURCE=200809L   sbuf.c
cc -c -pedantic -Wall -Wfatal-errors -std=c99 -D_POSIX_C_SOURCE=200809L   ren.c
cc -c -pedantic -Wall -Wfatal-errors -std=c99 -D_POSIX_C_SOURCE=200809L   led.c
cc -c -pedantic -Wall -Wfatal-errors -std=c99 -D_POSIX_C_SOURCE=200809L   uc.c
cc -c -pedantic -Wall -Wfatal-errors -std=c99 -D_POSIX_C_SOURCE=200809L   term.c
cc -c -pedantic -Wall -Wfatal-errors -std=c99 -D_POSIX_C_SOURCE=200809L   regex.c
cc -c -pedantic -Wall -Wfatal-errors -std=c99 -D_POSIX_C_SOURCE=200809L   conf.c
cc -c -pedantic -Wall -Wfatal-errors -std=c99 -D_POSIX_C_SOURCE=200809L   hund.c
cc -o vi vi.o ex.o lbuf.o sbuf.o ren.o led.o uc.o term.o regex.o conf.o hund.o  -pedantic -Wall -Wfatal-errors -std=c99 -D_POSIX_C_SOURCE=200809L
/bin/ld: regex.o: in function `regexec':
regex.c:(.text+0x1b48): undefined reference to `brk_match'
/bin/ld: regex.c:(.text+0x21dd): undefined reference to `brk_match'
/bin/ld: regex.c:(.text+0x284d): undefined reference to `brk_match'
/bin/ld: regex.c:(.text+0x2ec6): undefined reference to `brk_match'
collect2: error: ld returned 1 exit status
make: *** [Makefile:11: vi] Error 1

And for the earlier commits that work:

$ git checkout fc92963
$ sudo make clean install
rm -f *.o vi
cc -c -pedantic -Wall -Wfatal-errors -std=c99 -D_POSIX_C_SOURCE=200809L   vi.c
cc -c -pedantic -Wall -Wfatal-errors -std=c99 -D_POSIX_C_SOURCE=200809L   ex.c
cc -c -pedantic -Wall -Wfatal-errors -std=c99 -D_POSIX_C_SOURCE=200809L   lbuf.c
cc -c -pedantic -Wall -Wfatal-errors -std=c99 -D_POSIX_C_SOURCE=200809L   sbuf.c
cc -c -pedantic -Wall -Wfatal-errors -std=c99 -D_POSIX_C_SOURCE=200809L   ren.c
cc -c -pedantic -Wall -Wfatal-errors -std=c99 -D_POSIX_C_SOURCE=200809L   led.c
cc -c -pedantic -Wall -Wfatal-errors -std=c99 -D_POSIX_C_SOURCE=200809L   uc.c
cc -c -pedantic -Wall -Wfatal-errors -std=c99 -D_POSIX_C_SOURCE=200809L   term.c
cc -c -pedantic -Wall -Wfatal-errors -std=c99 -D_POSIX_C_SOURCE=200809L   regex.c
cc -c -pedantic -Wall -Wfatal-errors -std=c99 -D_POSIX_C_SOURCE=200809L   conf.c
cc -c -pedantic -Wall -Wfatal-errors -std=c99 -D_POSIX_C_SOURCE=200809L   hund.c
cc -o vi vi.o ex.o lbuf.o sbuf.o ren.o led.o uc.o term.o regex.o conf.o hund.o  -pedantic -Wall -Wfatal-errors -std=c99 -D_POSIX_C_SOURCE=200809L
cp -f vi /bin

I wonder whats causing this problem (I dont know C).
Kindly look into this. Thanks.

@kyx0r
Copy link
Owner

kyx0r commented Jun 20, 2021

Hi @Inesgor what compiler are you using and version? I just pushed a commit that might fix the problem, thanks for the report. This is a very good catch because virtually with any modern compiler it would not give any warning about potential portability with the use of inline keyword.

@kyx0r
Copy link
Owner

kyx0r commented Jun 20, 2021

Right. I just figured out how to reproduce this on my side. Basically because of default -O0 optimization compiler generates symbols but also inlines the functions, without stripping the symbols so the linker tries to find references to them, which don't exist. This does not happen on higher optimization levels. The patch above solves the said issue.

@kyx0r kyx0r closed this as completed Jun 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants