Skip to content

[flang] Fix build with AVOID_NATIVE_UINT128_T #63712

@h-vetinari

Description

@h-vetinari

In trying to get flang usable in the conda-forge ecosystem (think of it as a cross-platform quasi-distribution; see #60730), One of the main remaining problems is that building and running flang against the MSVC runtime fails with a linkage error for the symbol __udivti3, which is in compiler-rt but not the MSVC runtime.

Linking to compiler-rt has its own set of problems, though, so I perked up when I stumbled over the following context for __udivti3:

Hans Wennborg: Sharing in case anyone else runs into the same problem: This caused Chromium builds to fail on Windows due to not linking against compiler-rt's builtins library. It turns out this patch caused us to compile some code doing 128-bit arithmetic and calling the __udivti3 runtime function. We worked around it by defining _LIBCPP_HAS_NO_INT128 until we can make the builtins library part of all our builds.

Mark de Wever: Interesting that this caused it. I expect the real cause is std::to_char for 128-bit values, there divisions are used. Does that mean the flag in __config is not set correctly? It was recently updated in D134912.

Even though flang doesn't use libcxx, I followed down this 128-bit rabbit hole a bit, and after some searching I found AVOID_NATIVE_UINT128_T. However, even having built flang with that (plus 21bff9c), it still runs into missing __udivti3 when trying to build a hello-world example.

I ended up asking if building flang without native 128-bit types considered supported, and got the following response:

@vzakhari: I do not think building with AVOID_NATIVE_UINT128_T is being tested or/and is fully functional. I remember trying to experimentally enable it would fail the runtime compilation because of the missing type conversion operators. The most reliable way to make sure that AVOID_NATIVE_UINT128_T works is to have at least one buildbot that uses it for Flang build and also runs some end-to-end testing. It seems to worth a separate issue.

Hence this issue. I don't know how hard it would be to set up an extra build bot, but that sounds like something that would be really helpful on platforms without native 128bit types, of which windows is a prime example.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions