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

The AWK script might not be portable? #1

Closed
hugomg opened this issue Jul 24, 2023 · 7 comments · Fixed by #2
Closed

The AWK script might not be portable? #1

hugomg opened this issue Jul 24, 2023 · 7 comments · Fixed by #2

Comments

@hugomg
Copy link
Member

hugomg commented Jul 24, 2023

pallene-lang/pallene#516 (comment)

  • BEGINFILE might be a GNU-ism
  • Somehow it's including itself in the generated luacore.h?
@hugomg
Copy link
Member Author

hugomg commented Jul 24, 2023

@Nomarian, could you please tell us more about what system you're using? Is it not GNU Awk?

I'm not sure it would be the best idea to switch this to a Lua script, because needing Lua to build the custom Lua is a bit of a chicken-egg problem. Perhaps it would be simpler to provide tarballs that already contain the generated luacore.h? Is there an easy/automated way to do that on Github?

@Nomarian
Copy link

The solution is changing BEGINFILE to FNR==1, I've attached a diff on some other changes.

luacore.diff.txt

I'm also a bit worried about get-lua-core-h.awk being mentioned twice in the make output.

awk -f gen-lua-core-h.awk gen-lua-core-h.awk llimits.h lctype.h lopcodes.h lmem.h lobject.h lzio.h ltable.h lfunc.h ltm.h lparser.h llex.h lundump.h lstate.h lcode.h ldebug.h lapi.h ldo.h lgc.h lvm.h lstring.h > luacore.h  

I should mention, pallene builds succesfully, its only when you { pallenenc script.pln } that it fails. even when you --emit-c

@Nomarian
Copy link

perhaps using a lua script is a no, considering building pallene when you already have lua installed is slightly more complicated (luarocks does not accept --with-lua correctly but that's another matter)

@Nomarian
Copy link

POSIX awk spec

FWIW, BEGINFILE only exists in gawk, not even busybox awk or goawk have it.

@hugomg
Copy link
Member Author

hugomg commented Jul 24, 2023

Does changing to FNR==1 fix that failure you're having?

I'm also a bit worried about get-lua-core-h.awk being mentioned twice in the make output.

Basically, we want to tell make to regenerate luacore.h if either the AWK script or any of the core headers change. Furthermore, the script wants to receive the list of core header files. Currently we're passing the whole $^ which also includes the awk script itself, which we then try to skip with that broken if_header check. Ideally we'd tell the makefile to only pass the header files to the generator script, but I didn't know how to do that in portable make. Any ideas?

@hugomg
Copy link
Member Author

hugomg commented Jul 24, 2023

I had an idea... @Nomarian, could you please check if that PR helps?

hugomg added a commit that referenced this issue Jul 25, 2023
@Nomarian
Copy link

Nomarian commented Jul 25, 2023

Compiles and its even better than using FNR==1

@hugomg hugomg closed this as completed in #2 Jul 25, 2023
hugomg added a commit that referenced this issue Jul 25, 2023
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

Successfully merging a pull request may close this issue.

2 participants