Skip to content

Commit

Permalink
[LinkerWrapper][NFC] Rename 'all' to 'generic' for architecture agnos…
Browse files Browse the repository at this point in the history
…tic IR

Summary:
A previous patch introduced `all` as a special architecture. I have
decided I do not like this name and have changed it to `generic`.
  • Loading branch information
jhuber6 committed Feb 12, 2024
1 parent afa413a commit f5fd0de
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
8 changes: 8 additions & 0 deletions clang/docs/ClangLinkerWrapper.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,14 @@ linking is desired, simply do not run the binaries through the
``clang-linker-wrapper``. This will simply append the embedded device code so
that it can be linked later.

Matching
========

The linker wrapper will link extracted device code that is compatible with each
other. Generally, this requires that the target triple and architecture match.
An exception is made when the architecture is listed as ``generic``, which will
cause it be linked with any other device code with the same target triple.

Example
=======

Expand Down
2 changes: 1 addition & 1 deletion clang/test/Driver/linker-wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ __attribute__((visibility("protected"), used)) int x;
// AMD-TARGET-ID: clang{{.*}} -o {{.*}}.img --target=amdgcn-amd-amdhsa -mcpu=gfx90a:xnack- -O2 -Wl,--no-undefined {{.*}}.o {{.*}}.o

// RUN: clang-offload-packager -o %t-lib.out \
// RUN: --image=file=%t.elf.o,kind=openmp,triple=amdgcn-amd-amdhsa,arch=all
// RUN: --image=file=%t.elf.o,kind=openmp,triple=amdgcn-amd-amdhsa,arch=generic
// RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.o -fembed-offload-object=%t-lib.out
// RUN: llvm-ar rcs %t.a %t.o
// RUN: clang-offload-packager -o %t1.out \
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Object/OffloadBinary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ bool object::areTargetsCompatible(const OffloadFile::TargetID &LHS,
return false;

// If the architecture is "all" we assume it is always compatible.
if (LHS.second.equals("all") || RHS.second.equals("all"))
if (LHS.second.equals("generic") || RHS.second.equals("generic"))
return true;

// Only The AMDGPU target requires additional checks.
Expand Down

0 comments on commit f5fd0de

Please sign in to comment.