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

Yet another luajit.cmake unwind detection fix #614

Merged
merged 1 commit into from
Sep 8, 2022

Conversation

squeek502
Copy link
Member

@squeek502 squeek502 commented Sep 7, 2022

For reference, this is the logic we're trying to copy from LuaJIT's makefile:

https://github.com/LuaJIT/LuaJIT/blob/03080b795aa3496ed62d4a0697c9f4767e7ca7e5/src/Makefile#L339


Previously, CMake would only read up to the first NUL or control character (for me that meant it would only read "ELF" from tmpunwind.o). This was making CMake think there was no eh_frame/__unwind_info string in the file even if there actually was one.

Now, CMake skips binary data in tmpunwind.o and just reads all the ASCII strings from the file, which is fine for what we need to do with it.

This fixes:

In file included from luv/deps/luajit/src/ljamalg.c:23:
luv/deps/luajit/src/lj_err.c: In function ‘lj_err_unwind_dwarf’:
luv/deps/luajit/src/lj_err.c:469:2: error: #error "Broken build system -- only use the provided Makefiles!"
  469 | #error "Broken build system -- only use the provided Makefiles!"
      |  ^~~~~

for me on Linux x86_64 when trying to build Luv (unsure why this wasn't being hit in CI)


CMake MESSAGE output from when I was debugging:

Before (incorrect, TMPUNWIND_O should include more than just ELF and EH_FRAME_FOUND should not be -1):

-- TMPUNWIND_O: ELF
-- EH_FRAME_FOUND: -1
-- UNWIND_INFO_FOUND: -1

After (correct, eh_frame does exist in tmpunwind.o):

-- TMPUNWIND_O: ELF;>;@;@;UH;];GCC: (Ubuntu 10.3.0-1ubuntu1~20.04) 10.3.0;GNU;zR;x;E;C;K;%;tmpunwind.c;a;_GLOBAL_OFFSET_TABLE_;b;	; ;.symtab;.strtab;.shstrtab;.rela.text;.data;.bss;.comment;.note.GNU-stack;.note.gnu.property;.rela.eh_frame; ;@;@; ;;&;T;,;T;1;0;T;,;:;J; ;b;8;];@;8;; ;	;	;';P;l
-- EH_FRAME_FOUND: 215
-- UNWIND_INFO_FOUND: -1

Previously, CMake would only read up to the first NUL or control character (for me that meant it would only read "ELF" from tmpunwind.o).
This was making CMake think there was no `eh_frame`/`__unwind_info` string in the file even if there actually was.

Now, CMake skips binary data in tmpunwind.o and just reads all the ASCII strings from the file, which is fine for what we need to do with it.

This fixes:

    In file included from luv/deps/luajit/src/ljamalg.c:23:
    luv/deps/luajit/src/lj_err.c: In function ‘lj_err_unwind_dwarf’:
    luv/deps/luajit/src/lj_err.c:469:2: error: #error "Broken build system -- only use the provided Makefiles!"
      469 | #error "Broken build system -- only use the provided Makefiles!"
          |  ^~~~~

for me on Linux x86_64 when trying to build Luv
@zhaozg zhaozg merged commit ebc79ee into luvit:master Sep 8, 2022
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 this pull request may close these issues.

2 participants