llvm / llvm/llvm-project

clang modules incompatible between windows and linux

Open
#174,037 1 comment 0 reactions 1 assignee Claimed by @matts1 View on GitHub
clang:modules
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

The scheduler for the build system I use has the ability to start the job both locally and remotely, and uses the output of whichever one finishes first.

All our remote executors use linux, which means that the following is possible if compiling from a windows host.

#### Compile a PCM
```
# Remotely cross-compiling to windows from a linux worker
clang-cl ... foo/bar.h -emit-module -o out/foo/bar.pcm
# Locally compiling from your windows host
clang-cl.exe ... foo/bar.h -emit-module -o out/foo/bar.pcm
```

#### Use the PCM
```
# From a remote worker
clang-cl ... -fmodule-file=out/foo/foo.pcm
# From a local worker
clang-cl.exe ... -fmodule-file=out/foo/foo.pcm
```

The problem is that the PCM generated by a windows host is incompatible with linux. More specifically, when you attempt to use it, you get the error:
```
fatal error: malformed or corrupted precompiled file: 'could not find file 'foo\bar.h' referenced by AST file 'out/foo/foo.pcm''
```
Upon digging deeper, the root cause appears to be that the generated pcm file references `foo\bar.h` (a windows path with a backslash), instead of `foo/bar.h` (a unix path with a forward slash).

In order to ensure that clang on different platforms outputs the same PCM file, I thus propose that we:
* If on windows, normalize all paths to unix paths upon writing the PCM file
* If on windows, restore windows paths upon reading the PCM file

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.