-
Notifications
You must be signed in to change notification settings - Fork 1
[DTLTO] Normalize Windows 8.3 short paths to long form #4
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
base: dtlto_elf_lld
Are you sure you want to change the base?
Changes from 2 commits
1680a58
d24e531
2ca44d9
c2a3334
f90d4fd
b96acc2
9d4d009
0207d9f
0a7560d
f858814
ccd3e92
649e0fa
d102386
826a250
fa8c95f
0026ef6
7227c20
2bf19f1
f3394d0
057b7c3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Tests for DTLTO (Integrated Distributed ThinLTO) functionality. | ||
|
||
These are integration tests as DTLTO invokes `clang` for code-generation. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# REQUIRES: x86-registered-target,ld.lld,llvm-ar | ||
|
||
# Test that a DTLTO link succeeds and outputs the expected set of files | ||
# correctly when thin archives are present. | ||
|
||
RUN: rm -rf %t && split-file %s %t && cd %t | ||
RUN: %clang --target=x86_64-linux-gnu -flto=thin -c \ | ||
RUN: foo.c bar.c dog.c cat.c _start.c | ||
|
||
RUN: llvm-ar rcs foo.a foo.o --thin | ||
# Create this bitcode thin archive in a subdirectory to test the expansion of | ||
# the path to a bitcode file that is referenced using "..", e.g., in this case | ||
# "../bar.o". | ||
RUN: mkdir lib | ||
RUN: llvm-ar rcs lib/bar.a bar.o --thin | ||
# Create this bitcode thin archive with an absolute path entry containing "..". | ||
RUN: llvm-ar rcs dog.a %t/lib/../dog.o --thin | ||
RUN: llvm-ar rcs cat.a cat.o --thin | ||
RUN: llvm-ar rcs _start.a _start.o --thin | ||
|
||
RUN: mkdir %t/out && cd %t/out | ||
|
||
RUN: ld.lld %t/foo.a %t/lib/bar.a ../_start.a %t/cat.a \ | ||
RUN: --whole-archive ../dog.a \ | ||
RUN: --thinlto-distributor=%python \ | ||
RUN: --thinlto-distributor-arg=%llvm_src_root/utils/dtlto/local.py \ | ||
RUN: --thinlto-remote-compiler=%clang \ | ||
RUN: --save-temps | ||
|
||
# Check that the required output files have been created. | ||
RUN: ls | FileCheck %s --check-prefix=OUTPUTS \ | ||
RUN: --implicit-check-not=cat --implicit-check-not=foo | ||
|
||
# JSON jobs description. | ||
OUTPUTS-DAG: a.[[PID:[a-zA-Z0-9_]+]].dist-file.json | ||
|
||
# Individual summary index files. | ||
OUTPUTS-DAG: dog.1.[[PID]].native.o.thinlto.bc{{$}} | ||
OUTPUTS-DAG: _start.2.[[PID]].native.o.thinlto.bc{{$}} | ||
OUTPUTS-DAG: bar.3.[[PID]].native.o.thinlto.bc{{$}} | ||
|
||
# Native output object files. | ||
OUTPUTS-DAG: dog.1.[[PID]].native.o{{$}} | ||
OUTPUTS-DAG: _start.2.[[PID]].native.o{{$}} | ||
OUTPUTS-DAG: bar.3.[[PID]].native.o{{$}} | ||
|
||
#--- foo.c | ||
__attribute__((retain)) void foo() {} | ||
|
||
#--- bar.c | ||
extern void foo(); | ||
__attribute__((retain)) void bar() { foo(); } | ||
|
||
#--- dog.c | ||
__attribute__((retain)) void dog() {} | ||
|
||
#--- cat.c | ||
__attribute__((retain)) void cat() {} | ||
|
||
#--- _start.c | ||
extern void bar(); | ||
__attribute__((retain)) void _start() { | ||
bar(); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// REQUIRES: x86-registered-target,ld.lld | ||
|
||
/// Simple test that DTLTO works with a single input bitcode file and that | ||
/// --save-temps can be applied to the remote compilation. | ||
// RUN: rm -rf %t && mkdir %t && cd %t | ||
|
||
// RUN: %clang --target=x86_64-linux-gnu -c -flto=thin %s | ||
|
||
// RUN: ld.lld dtlto.o \ | ||
// RUN: --thinlto-distributor=%python \ | ||
// RUN: --thinlto-distributor-arg=%llvm_src_root/utils/dtlto/local.py \ | ||
// RUN: --thinlto-remote-compiler=%clang \ | ||
// RUN: --thinlto-remote-compiler-arg=--save-temps | ||
|
||
/// Check that the required output files have been created. | ||
// RUN: ls | count 10 | ||
// RUN: ls | FileCheck %s | ||
|
||
/// Produced by the bitcode compilation. | ||
// CHECK-DAG: {{^}}dtlto.o{{$}} | ||
|
||
/// Linked ELF. | ||
// CHECK-DAG: {{^}}a.out{{$}} | ||
|
||
/// --save-temps output for the backend compilation. | ||
// CHECK-DAG: {{^}}dtlto.s{{$}} | ||
// CHECK-DAG: {{^}}dtlto.s.0.preopt.bc{{$}} | ||
// CHECK-DAG: {{^}}dtlto.s.1.promote.bc{{$}} | ||
// CHECK-DAG: {{^}}dtlto.s.2.internalize.bc{{$}} | ||
// CHECK-DAG: {{^}}dtlto.s.3.import.bc{{$}} | ||
// CHECK-DAG: {{^}}dtlto.s.4.opt.bc{{$}} | ||
// CHECK-DAG: {{^}}dtlto.s.5.precodegen.bc{{$}} | ||
// CHECK-DAG: {{^}}dtlto.s.resolution.txt{{$}} | ||
|
||
int _start() { return 0; } |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
if "clang" not in config.available_features: | ||
config.unsupported = True |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# REQUIRES: x86-registered-target,ld.lld,llvm-ar | ||
|
||
# Check that any shortened "8.3" paths containing '~' characters are expanded, | ||
# and their path seperators changed to Winodws style ones, prior to being passed | ||
bd1976bris marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# to SN-DBS during DTLTO. | ||
bd1976bris marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
RUN: rm -rf %t && split-file %s %t && cd %t | ||
|
||
# Create an archive to confirm unpacked member paths are expanded. | ||
RUN: prospero-clang --target=x86_64-linux-gnu -c start.c f.c -flto=thin -O2 | ||
RUN: prospero-llvm-ar rcs libf.a f.o --thin | ||
bd1976bris marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
RUN: %python in-tilde-dir.py \ | ||
RUN: ld.lld start.o libf.a -o start.elf \ | ||
RUN: --thinlto-distributor=%python \ | ||
RUN: --thinlto-distributor-arg=%llvm_src_root/utils/dtlto/local.py \ | ||
RUN: --thinlto-remote-compiler=%clang \ | ||
RUN: --save-temps | ||
|
||
# Ensure that cross-module importing occurred. Cross-module importing is somewhat | ||
# fragile - e.g. it requires amenable code and compilation with -O2 or above. | ||
# It's important that importing happens for this test case, as the paths to | ||
# imported-from modules are recorded in the ThinLTO metadata. | ||
RUN: prospero-llvm-objdump -d start.elf | tee d.txt | FileCheck %s --check-prefix=IMPORT | ||
bd1976bris marked this conversation as resolved.
Show resolved
Hide resolved
|
||
IMPORT: <_start>: | ||
IMPORT: jmp 0x{{[0-9A-F]+}} <_start> | ||
IMPORT: <f>: | ||
IMPORT-NEXT: jmp 0x{{[0-9A-F]+}} <f> | ||
|
||
RUN: FileCheck --input-file start.*.dist-file.json %s --check-prefix=TILDE | ||
TILDE-NOT: ~ | ||
|
||
#--- f.c | ||
int _start(); | ||
int f() { return _start(); } | ||
|
||
#--- start.c | ||
int f(); | ||
int _start() { return f(); } | ||
|
||
#--- in-tilde-dir.py | ||
import os, shutil, sys, uuid, subprocess | ||
from pathlib import Path | ||
|
||
temp = Path(os.environ['TEMP']) | ||
assert temp.is_dir() | ||
|
||
# Copy the CWD to a unique directory inside TEMP and determine its 8.3 form. | ||
# TEMP is likely to be on a drive that supports long+short paths. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This isn't guaranteed. So we ought to handle the case where short paths are not enabled. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. In fact I feel like this was addressed already and I have just dropped a commit somewhere along the line.. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done now. I have used ctypes and python to query Win32s AreShortPathsEnabled function if it is available in the lit config for the cross-project tests. |
||
d = (temp / str(uuid.uuid4()) / 'veryverylong').resolve() | ||
d83 = d.parent / (d.name[:6] + '~1') | ||
d.parent.mkdir(parents=True) | ||
try: | ||
shutil.copytree(Path.cwd(), d) | ||
|
||
# Replace the arguments of the command that name files with equivalents in | ||
# our temp directory, prefixed with the 8.3 form. | ||
cmd = [a if not Path(a).is_file() else str(d83/a) \ | ||
for a in sys.argv[1:]] | ||
print(cmd) | ||
|
||
sys.exit(subprocess.run(cmd).returncode) | ||
|
||
finally: | ||
shutil.rmtree(d.parent) |
Uh oh!
There was an error while loading. Please reload this page.