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

pythonh: Function type does not match previously declared function with the same mangled name: stat64 #271

Open
andre2007 opened this issue Aug 13, 2020 · 5 comments
Labels
bug workaround A workaround exists

Comments

@andre2007
Copy link

This dockerfile

FROM python:3.7

RUN apt-get update && apt-get upgrade -y \
    && apt-get install --no-install-recommends -y curl gcc clang-7 libclang-7-dev python3 python3-dev xz-utils \
    && ln -s /usr/bin/clang-7 /usr/bin/clang

WORKDIR /tmp
RUN curl -OL https://github.com/ldc-developers/ldc/releases/download/v1.22.0/ldc2-1.22.0-linux-x86_64.tar.xz \
    && tar -xf ldc2-1.22.0-linux-x86_64.tar.xz --strip-components=1 -C /

RUN echo '#include <python3.7/Python.h>' > pythonh.dpp
RUN DFLAGS="-L=-L/usr/lib/llvm-7/lib/" dub run dpp -- pythonh.dpp \
    --preprocess-only

will produce a file pythonh.d which contains this coding

pragma(mangle, "stat64") int stat64_(const(char)*, stat64*) @nogc nothrow;
int fstat(int, stat*) @nogc nothrow;
pragma(mangle, "stat64") int stat_(const(char)*, stat*) @nogc nothrow;

LDC2 complains:

pythonh.d(150): Error: Function type does not match previously declared function with the same mangled name: stat64
pythonh.d(150): Previous IR type: i32 (i8*, %pythonh.stat64*)
pythonh.d(150): New IR type: i32 (i8*, %pythonh.stat*)

@atilaneves atilaneves added the workaround A workaround exists label Aug 26, 2020
@atilaneves
Copy link
Owner

Ah. I never noticed it before because I only ever used dmd on the result and ldc is a bit more of a stickler wrt duplicate symbols. A workaround for now is to use dmd instead.

@atilaneves atilaneves added the bug label Aug 26, 2020
@atilaneves
Copy link
Owner

For some reason libclang is returning "stat64" as the mangling for "stat" even though, as C linkage functions, they don't mangle!

@atilaneves
Copy link
Owner

I'm racking my head how to solve this without having to try and reduce the issue with libclang. There's no good way to know if the cursor is C or C++ (thereby avoiding any mangling whatsoever if not needed, as is the case here). There's a function to get the language, but it returns "C" for any and all functions regardless of them being extern "C" or not. There's a function to get linkage, but it doesn't do what you'd expect and basically tells you if a cursor is extern or not.

@Laeeth
Copy link

Laeeth commented Aug 26, 2020 via email

@andre2007
Copy link
Author

If my understanding is correct, with this pr it will be a deprecation warning also with DMD dlang/dmd#8429

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug workaround A workaround exists
Projects
None yet
Development

No branches or pull requests

3 participants