Hello there,

I am looking for some help with how to relocate prebuilt modules.
My desired workflow is:
- prebuild modules on host
- copy modules to a target
- use the prebuilt modules on target through `-fprebuilt-module-path`.
My attempts are failing, as it seems the absolute path to the modules when
compiled is embedded in the PCMs.

Recreating the target path to prebuilt modules on the host does not look
like an option, as:
- the target path would be within a path that users do not have permissions
to on the host
- I'd rather not touch anything out of the project build tree.

Am I missing the correct way to do this?

For reference, below is a simple test-case highlighting the issue.

Cheers!

Alexandre


#!/bin/bash

set -x

rm -rf build prebuilt_modules

cat << EOF > module.modulemap
module foo { header "foo.h" }
module bar { header "bar.h" }
EOF

cat << EOF > foo.h
// empty
EOF

cat << EOF > bar.h
#include "foo.h"
EOF

cat <<EOF > use.c
#include "bar.h"
EOF

# Prebuild modules
clang -cc1 -x c -fmodules -fno-implicit-modules module.modulemap
-fmodule-name=foo -emit-module -o build/prebuilt_modules/foo.pcm
clang -cc1 -x c -fmodules -fno-implicit-modules module.modulemap
-fmodule-name=bar -emit-module -o build/prebuilt_modules/bar.pcm
-fprebuilt-module-path=build/prebuilt_modules

# Using them in-place works fine.
clang -cc1 -x c -fmodules -fmodule-map-file=module.modulemap
-fno-implicit-modules use.c -o /dev/null
-fprebuilt-module-path=build/prebuilt_modules

# Relocating and using fails.
mv build/prebuilt_modules prebuilt_modules
clang -cc1 -x c -fmodules -fmodule-map-file=module.modulemap
-fno-implicit-modules use.c -o /dev/null
-fprebuilt-module-path=prebuilt_modules
#     use.c:1:2: fatal error: module file
'./build/prebuilt_modules/foo.pcm' not found: module file not found
#     #include "bar.h"
#      ^
#     use.c:1:2: note: imported by module 'bar' in
'/Volumes/work/topics/modules/relocation/example/prebuilt_modules/bar.pcm'
_______________________________________________
cfe-users mailing list
cfe-users@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users

Reply via email to