CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
78 lines
2.4 KiB
Plaintext
78 lines
2.4 KiB
Plaintext
## On Windows co-operative applications can be expected to open LLD's output
|
|
## with FILE_SHARE_DELETE included in the sharing mode. This allows us to link
|
|
## over the top of an existing file even if it is in use by another application.
|
|
|
|
# REQUIRES: system-windows, x86
|
|
# RUN: echo '.globl _start; _start:' > %t.s
|
|
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-unknown %t.s -o %t.o
|
|
|
|
## FILE_SHARE_READ = 1
|
|
## FILE_SHARE_WRITE = 2
|
|
## FILE_SHARE_DELETE = 4
|
|
|
|
# RUN: %python %s %t.o 7 false
|
|
# RUN: not %python %s %t.o 3 false 2>&1 | FileCheck %s
|
|
# RUN: %python %s %t.o 7 true
|
|
# RUN: not %python %s %t.o 3 true 2>&1 | FileCheck %s
|
|
# CHECK: error: failed to write output '{{.*}}': {{.*}}
|
|
|
|
import contextlib
|
|
import ctypes
|
|
from ctypes import wintypes as w
|
|
import os
|
|
import shutil
|
|
import subprocess
|
|
import platform
|
|
import sys
|
|
import time
|
|
|
|
object_file = sys.argv[1]
|
|
share_flags = int(sys.argv[2])
|
|
use_mmap = bool(sys.argv[3])
|
|
|
|
@contextlib.contextmanager
|
|
def open_with_share_flags(filename, share_flags):
|
|
GENERIC_READ = 0x80000000
|
|
FILE_ATTRIBUTE_NORMAL = 0x80
|
|
OPEN_EXISTING = 0x3
|
|
INVALID_HANDLE_VALUE = w.HANDLE(-1).value
|
|
|
|
CreateFileA = ctypes.windll.kernel32.CreateFileA
|
|
CreateFileA.restype = w.HANDLE
|
|
h = CreateFileA(filename.encode('mbcs'), GENERIC_READ, share_flags,
|
|
None, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, None)
|
|
|
|
assert h != INVALID_HANDLE_VALUE, 'Failed to open ' + filename
|
|
try:
|
|
yield
|
|
finally:
|
|
ctypes.windll.kernel32.CloseHandle(h)
|
|
|
|
## Ensure we have an empty directory for the output.
|
|
outdir = os.path.basename(__file__) + '.dir'
|
|
if os.path.exists(outdir):
|
|
shutil.rmtree(outdir)
|
|
os.makedirs(outdir)
|
|
|
|
## Link on top of an open file.
|
|
elf = os.path.join(outdir, 'output_file.elf')
|
|
open(elf, 'wb').close()
|
|
with open_with_share_flags(elf, share_flags):
|
|
args = ['ld.lld.exe', object_file, '-o', elf]
|
|
if use_mmap:
|
|
args.append("--mmap-output-file")
|
|
subprocess.check_call(args)
|
|
|
|
## Check the linker wrote the output file.
|
|
with open(elf, 'rb') as f:
|
|
assert f.read(4) == b'\x7fELF', "linker did not write output file correctly"
|
|
|
|
## Check no temp files are left around.
|
|
## It might take a while for Windows to remove them, so loop.
|
|
deleted = lambda: len(os.listdir(outdir)) == 1
|
|
for _ in range(10):
|
|
if not deleted():
|
|
time.sleep (1)
|
|
|
|
assert deleted(), "temp file(s) not deleted after grace period"
|