llvm-cbe generates missing l_fptr_1 from .ll ouput from clang++-10 (plzip-1.9 dec_stdout.c) #132
Closed
Description
Say, we have LLVM 10.0.0, and just have built llvm-cbe
in current directory.
Trying to build dec_stdout.cc
from plzip-1.9
with lzlib-1.12
:
wget -q http://download.savannah.gnu.org/releases/lzip/lzlib/lzlib-1.12.tar.gz
wget -q http://download.savannah.gnu.org/releases/lzip/plzip/plzip-1.9.tar.gz
tar xf plzip-1.9.tar.gz
tar xf lzlib-1.12.tar.gz
clang++-10 -S -emit-llvm -g -Iplzip-1.9 -Ilzlib-1.12 -o dec_stdout.ll plzip-1.9/dec_stdout.cc
./llvm-cbe dec_stdout.ll
gcc-10 -Wno-builtin-declaration-mismatch -Wno-address-of-packed-member -c -o dec_stdout.o dec_stdout.cbe.c
I have the following output then (among the message caused by #138):
dec_stdout.cbe.c:466:78: error: unknown type name ‘l_fptr_1’
466 | uint32_t pthread_create(uint64_t*, struct l_struct_union_OC_pthread_attr_t*, l_fptr_1*, uint8_t*) __ATTRIBUTELIST__((nothrow));
| ^~~~~~~~
/usr/src-remote/llvm/llvm-cbe/build-10/tools/llvm-cbe/plzip-1.9/dec_stdout.cc: In function ‘_Z10dec_stdoutiiiRK12Pretty_printiiRK10Lzip_index’:
/usr/src-remote/llvm/llvm-cbe/build-10/tools/llvm-cbe/plzip-1.9/dec_stdout.cc:309:10: warning: implicit declaration of function ‘pthread_create’ [-Wimplicit-function-declaration]
309 | }
| ^
If we grep dec_stdout.cbe.c
for l_fptr_1
, we'll figure out it's not declared (and, since it's in declaration of pthread_create()
, this function appears undeclared after a while):
uint32_t pthread_create(uint64_t*, struct l_struct_union_OC_pthread_attr_t*, l_fptr_1*, uint8_t*) __ATTRIBUTELIST__((nothrow));
I expected hacking first call to clang++-10
with something like -pthread
, -include /usr/include/pthread.h
would help with that; but I had no success (and about LLVMMul_uov
, I really have no idea--there is no such declaration in the whole /usr/include
).
Of course, calling clang to compile instead of generate .ll
succeeds. Called like this:
clang++-10 -S -c -g -Iplzip-1.9 -Ilzlib-1.12 -o dec_stdout.o plzip-1.9/dec_stdout.cc
Metadata
Assignees
Labels
No labels
Activity
hikari-no-yume commentedon May 27, 2021
I recently fixed another issue involving missing
l_fptr
types: #101I wonder if this is a similar type of issue.
Edit: In fact it sounds very similar, so I am surprised it is happening. I will probably have a look at it soon.
makise-homura commentedon May 28, 2021
@hikari-no-yume Looks like so. Still reproducible in current master.
By the way, I figured out simple examples how to get these errors.
This one (
pthread_test.c
):Building (specifying or skipping
-pthread
on call to either clang, gcc, or both does not matter):Other one is now moved to #138, as you proposed.
Clang and gcc versions:
hikari-no-yume commentedon May 28, 2021
Thanks for the reproducers. The pthread one works for getting the unknown type name error for me, even though I am on macOS. I guess this works because pthreads is a common POSIX API. (Edit: #135 should fix it.)
I haven't tried the second reproducer yet. If it is not too much hassle, could you make a separate issue for that one? Though the errors may seem similar, I think it is likely to be caused by a different part of the CBE code.
makise-homura commentedon Jun 10, 2021
Sorry for late reply, I was on kind of vacation and had no access to host where I was experimenting with this. Now I got back to this. Created #138, and edited this issue to focus on pthread-related stuff.
makise-homura commentedon Jun 10, 2021
By the way, I tried the branch from #135, and it does not reproduce there both with
pthread_test.c
(a call togcc-10
should be with-pthread
option added), and with originaldec_stdout.cc
(but latter still suffers from #138).