Skip to content

clang on a Windows host keeps \ in __FILE__ for a POSIX target under -ffile-reproducible: an ok image built on Windows differs from one built on Linux/macOS #850

Duplicate

Description

@Sunrisepeak

Observation

An ok image (x86_64-openkal) built on a Windows host is not the bytes of the same image built on Linux or macOS. The difference is two __FILE__ strings from libc++abi's demangler:

Built on Strings in the image
Linux, macOS (identical images) openkal-llvm-runtime@0.16.6/llvm/libcxxabi/src/demangle/ItaniumDemangle.h, …/src/demangle/Utility.h
Windows openkal-llvm-runtime@0.16.6/llvm/libcxxabi/src\demangle/ItaniumDemangle.h, …/src\demangle\Utility.h

Measured with a probe building one image (import std, an exception, std::source_location, [profile.release] trim_paths = true) with mcpp release/2026.10.27.1 and llvm@23.1.3 on ubuntu-24.04, macos-15 and windows-2022 (mcpplibs/openkal-platform, branch probe/image-bytes). The Linux and macOS images share one sha256; the Windows one differs in 3,921 bytes, all following from those two strings (.rodata, then .text and .rela.dyn offsets).

Cause (upstream)

cxa_demangle.cpp includes "demangle/ItaniumDemangle.h", found relative to the includer's directory; clang joins that directory and the spelled name with the host's separator (llvm::sys::path::append, native style), so on Windows the path is …/src\demangle/ItaniumDemangle.h. mcpp maps the package's prefix (-ffile-prefix-map) and, since #847, passes -ffile-reproducible with trim_paths. -ffile-reproducible is documented as using the target's separator in __FILE__, but for a non-Windows target Preprocessor::processPathForFileMacro only calls remove_dots(…, Style::posix), which does not treat \ as a separator, so the host's separator stays. For a Windows target the flag does normalise (to \).

Consequence

Workaround in mcpp

None in the build: the joined directory is the includer's and depends on which files include which, so a prefix map per directory of every package would be needed, which the command-line length on Windows does not allow for packages of libc++'s size. The packaging spec states the rule (SPEC-014 §4.6) and the release notes do not claim host-independent images for Windows hosts.

To be reported to LLVM: -ffile-reproducible keeps the host's \ in __FILE__ for a POSIX target when the path was joined on a Windows host.

Activity

  1. added
    upstream-bug
    on Oct 28, 2026
  2. speak-agent commented on Nov 26, 2026

    @speak-agent
    Member

    Moved to the upstream defects register, #1027: UP-06.

    The entry states what is measured, what mcpp does about it and when it is retired. This report stays as the full record and reproduction; a new measurement or a change of workaround goes to the entry's comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    upstream-bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions