[AIX][XCOFF] print unsupported message for llvm-ar big archive write operation

Summary:

when run "llvm-ar cr" on AIX OS , it created a gnu archive, it is not desirable in aix OS.
instead of creating a gnu archive, the patch will print a unsupport message for llvm-ar big archive write operation in AIX OS.

after implement the big archive operation, I will revert the XFAIL: AIX " and "--format=gnu" test cases in the patch.

Reviewer : James Henderson, Jinsong Ji
Differential Revision: https://reviews.llvm.org/D122746
This commit is contained in:
zhijian 2022-04-01 11:55:11 -04:00
parent f8101e4d68
commit cad178274c
39 changed files with 65 additions and 11 deletions

View File

@ -1,3 +1,4 @@
XFAIL: system-aix
Test which operations create an archive and which don't.
RUN: touch %t

View File

@ -1,3 +1,5 @@
XFAIL: system-aix
RUN: mkdir -p %t
RUN: cd %t
RUN: rm -rf foo

View File

@ -1,3 +1,4 @@
# XFAIL: system-aix
## Show that the archive library emits error messages when adding malformed
## objects.

View File

@ -1,3 +1,5 @@
XFAIL: system-aix
Test adding a member to a particular position
RUN: touch %t.foo

View File

@ -1,3 +1,4 @@
# XFAIL: system-aix
## Show that the archive library does not emit an error or add any symbols to
## the archive symbol table, when it encounters an unknown file type, but still
## adds the file to the archive.

View File

@ -1,3 +1,5 @@
XFAIL: system-aix
Test the 'u' option of llvm-ar
RUN: rm -rf %t && mkdir -p %t && cd %t

View File

@ -1,3 +1,5 @@
; XFAIL: system-aix
;RUN: rm -rf %t && mkdir -p %t
;RUN: not llvm-ar r %t/test.a . 2>&1 | FileCheck -DMSG=%errc_EISDIR %s
;CHECK: .: [[MSG]]

View File

@ -0,0 +1,3 @@
--- !XCOFF
FileHeader:
MagicNumber: 0x1DF

View File

@ -1,3 +1,4 @@
# XFAIL: system-aix
# Test the 'N' count parameter.
# Get a temp clean cwd to extract into.

View File

@ -1,3 +1,4 @@
XFAIL: system-aix
## Test the creation warning and supression of that warning.
RUN: touch %t1.txt

View File

@ -1,3 +1,4 @@
XFAIL: system-aix
# Test the use of dash before key letters.
RUN: touch %t1.txt

View File

@ -0,0 +1,10 @@
; REQUIRES: system-aix
;; Test llvm-ar does not support Big AIX archive write operation.
; RUN: yaml2obj %S/Inputs/xcoff.yaml -o %t.obj
; RUN: rm -f %t.ar
; RUN: not llvm-ar cr %t.ar %t.obj 2>&1 | FileCheck %s
; RUN: echo "test big archive" > %t.txt
; RUN: not llvm-ar cr %t.ar %t.txt 2>&1 | FileCheck %s
; CHECK: unsupported big AIX write operation

View File

@ -1,3 +1,4 @@
# XFAIL: system-aix
## Test the deletion of members and that symbols are removed from the symbol table.
# RUN: yaml2obj %s -o %t-delete.o --docnum=1

View File

@ -1,3 +1,4 @@
# XFAIL: system-aix
## Test Display of empty archives.
# RUN: rm -rf %t && mkdir -p %t

View File

@ -1,3 +1,4 @@
# XFAIL: system-aix
## Test the use of "--" on the commandline
# RUN: echo contents > %t.txt

View File

@ -1,3 +1,4 @@
# XFAIL: system-aix
## Unsupported on windows as marking files "unreadable"
## is non-trivial on windows.
# UNSUPPORTED: system-windows

View File

@ -1,5 +1,5 @@
## Test extract operation.
# XFAIL: system-darwin
# XFAIL: system-darwin,system-aix
# RUN: rm -rf %t && mkdir -p %t/extracted/

View File

@ -1,3 +1,4 @@
# XFAIL: system-aix
# This test creates a thin archive that contains a thin archive, a regular
# archive, and a file.
#

View File

@ -1,3 +1,4 @@
XFAIL: system-aix
# Note: many of these tests depend on relative paths, so we have to cd to a
# test directory first.
RUN: mkdir -p %t && cd %t

View File

@ -1,3 +1,4 @@
# XFAIL: system-aix
## Test archives do not convert to thin archives.
# RUN: rm -rf %t && mkdir -p %t

View File

@ -1,3 +1,4 @@
XFAIL: system-aix
## Test inserting files after a file.
RUN: touch %t1.txt

View File

@ -1,3 +1,4 @@
XFAIL: system-aix
## Test inserting files before a file.
RUN: touch %t1.txt

View File

@ -1,3 +1,4 @@
XFAIL: system-aix
## Test moving files after a file.
RUN: touch %t1.txt

View File

@ -1,3 +1,4 @@
XFAIL: system-aix
## Test moving files after a file.
RUN: touch %t1.txt

View File

@ -1,3 +1,4 @@
XFAIL: system-aix
RUN: yaml2obj %S/Inputs/elf.yaml -o %t.o
RUN: rm -f %t.ar

View File

@ -1,3 +1,4 @@
XFAIL: system-aix
# Test non-ascii archive members
RUN: rm -rf %t && mkdir -p %t/extracted

View File

@ -1,3 +1,4 @@
# XFAIL: system-aix
## Test that on windows, members are case insensitive.
# UNSUPPORTED: system-windows

View File

@ -1,3 +1,4 @@
# XFAIL: system-aix
## Test that --plugin is ignored.
# RUN: rm -f %t.a

View File

@ -1,5 +1,5 @@
## Test Print output
# XFAIL: system-darwin
# XFAIL: system-darwin,system-aix
# RUN: rm -rf %t && mkdir -p %t
# RUN: echo file1 > %t/1.txt

View File

@ -1,3 +1,4 @@
# XFAIL: system-aix
## Test quick append
# RUN: rm -rf %t && mkdir -p %t

View File

@ -1,3 +1,4 @@
# XFAIL: system-aix
## Test that read-only archives cannot be edited
# RUN: rm -rf %t && mkdir -p %t

View File

@ -1,3 +1,4 @@
# XFAIL: system-aix
## Check that response files can cope with non-ascii characters.
# RUN: echo 'contents' > %t-£.txt

View File

@ -1,3 +1,4 @@
# XFAIL: system-aix
## Test thin archives do not siletly convert to full archives on write.
# RUN: rm -f %tthin.a %tfull.a

View File

@ -1,3 +1,4 @@
# XFAIL: system-aix
## This test checks that an archive is flattened correctly.
# RUN: yaml2obj %S/Inputs/input1.yaml -o %t-input1.o

View File

@ -1,4 +1,4 @@
# RUN: llvm-ar cr %t.fg.a %S/Inputs/f.ll %S/Inputs/g.ll
# RUN: llvm-ar --format=gnu cr %t.fg.a %S/Inputs/f.ll %S/Inputs/g.ll
# RUN: not llvm-link %S/Inputs/h.ll %t.fg.a -o %t.linked.bc 2>&1 | FileCheck %s
# RUN: rm -f %t.fg.a

View File

@ -56,7 +56,7 @@ Symbols:
# RUN: yaml2obj --docnum=2 -DFLAG=0x1DF %s -o %t_xcoff32.o
# RUN: yaml2obj --docnum=2 -DFLAG=0x1F7 %s -o %t_xcoff64.o
# RUN: rm -f %t.a
# RUN: llvm-ar -q -c %t.a %t_xcoff32.o %t_xcoff64.o
# RUN: llvm-ar --format=gnu -q -c %t.a %t_xcoff32.o %t_xcoff64.o
# RUN: llvm-nm --format=just-symbols -X32 %t_xcoff32.o | \
# RUN: FileCheck --check-prefixes=XCOFF32 %s --implicit-check-not={{.}}

View File

@ -16,7 +16,7 @@ EMPTY: '{{.*}}.empty': The file was not recognized as a valid object file
# Test that unrecognised files in archives are ignored.
RUN: rm -f %t.a
RUN: llvm-ar rc %t.a %t.empty
RUN: llvm-ar --format=gnu rc %t.a %t.empty
RUN: llvm-readobj --all %t.a 2>&1 | FileCheck --check-prefix=NO-OUTPUT --allow-empty %s
NO-OUTPUT-NOT: {{.}}

View File

@ -5,21 +5,21 @@
## Case 1: Empty archive. No output expected.
# RUN: rm -f %t1.a
# RUN: llvm-ar rc %t1.a
# RUN: llvm-ar --format=gnu rc %t1.a
# RUN: llvm-size -B %t1.a | count 0
# RUN: llvm-size -A %t1.a | count 0
## Case 2: Single member.
# RUN: rm -f %t2.a
# RUN: llvm-ar rc %t2.a %t1
# RUN: llvm-ar --format=gnu rc %t2.a %t1
# RUN: llvm-size -B %t2.a | FileCheck %s -DARCHIVE=%t2.a --check-prefix=BERKELEY-1
# RUN: llvm-size -A %t2.a | FileCheck %s -DARCHIVE=%t2.a --check-prefix=SYSV-1
## Case 3: Multiple members.
# RUN: rm -f %t3.a
# RUN: llvm-ar rc %t3.a %t1 %t2
# RUN: llvm-ar --format=gnu rc %t3.a %t1 %t2
# RUN: llvm-size -B %t3.a | FileCheck %s -DARCHIVE=%t3.a --check-prefixes=BERKELEY-1,BERKELEY-2
# RUN: llvm-size -A %t3.a | FileCheck %s -DARCHIVE=%t3.a --check-prefixes=SYSV-1,SYSV-2

View File

@ -22,6 +22,7 @@
#include "llvm/Object/MachO.h"
#include "llvm/Object/ObjectFile.h"
#include "llvm/Object/SymbolicFile.h"
#include "llvm/Object/XCOFFObjectFile.h"
#include "llvm/Support/Chrono.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/ConvertUTF.h"
@ -881,9 +882,11 @@ computeNewArchiveMembers(ArchiveOperation Operation,
}
static object::Archive::Kind getDefaultForHost() {
return Triple(sys::getProcessTriple()).isOSDarwin()
Triple HostTriple(sys::getProcessTriple());
return HostTriple.isOSDarwin()
? object::Archive::K_DARWIN
: object::Archive::K_GNU;
: (HostTriple.isOSAIX() ? object::Archive::K_AIXBIG
: object::Archive::K_GNU);
}
static object::Archive::Kind getKindFromMember(const NewArchiveMember &Member) {
@ -894,7 +897,9 @@ static object::Archive::Kind getKindFromMember(const NewArchiveMember &Member) {
if (OptionalObject)
return isa<object::MachOObjectFile>(**OptionalObject)
? object::Archive::K_DARWIN
: object::Archive::K_GNU;
: (isa<object::XCOFFObjectFile>(**OptionalObject)
? object::Archive::K_AIXBIG
: object::Archive::K_GNU);
// squelch the error in case we had a non-object file
consumeError(OptionalObject.takeError());
@ -939,6 +944,8 @@ static void performWriteOperation(ArchiveOperation Operation,
else
Kind = !NewMembers.empty() ? getKindFromMember(NewMembers.front())
: getDefaultForHost();
if (Kind == object::Archive::K_AIXBIG)
fail("unsupported big AIX write operation");
break;
case GNU:
Kind = object::Archive::K_GNU;