
Early adoption of new technologies or adjusting certain code generation/IR optimization thresholds is often available through some cl::opt options (which have unstable surfaces). Specifying such an option twice will lead to an error. ``` % clang -c a.c -mllvm -disable-binop-extract-shuffle -mllvm -disable-binop-extract-shuffle clang (LLVM option parsing): for the --disable-binop-extract-shuffle option: may only occur zero or one times! % clang -c a.c -mllvm -hwasan-instrument-reads=0 -mllvm -hwasan-instrument-reads=0 clang (LLVM option parsing): for the --hwasan-instrument-reads option: may only occur zero or one times! % clang -c a.c -mllvm --scalar-evolution-max-arith-depth=32 -mllvm --scalar-evolution-max-arith-depth=16 clang (LLVM option parsing): for the --scalar-evolution-max-arith-depth option: may only occur zero or one times! ``` The option is specified twice, because there is sometimes a global setting and a specific file or project may need to override (or duplicately specify) the value. The error is contrary to the common practice of getopt/getopt_long command line utilities that let the last option win and the `getLastArg` behavior used by Clang driver options. I have seen such errors for several times. I think the error just makes users inconvenient, while providing very little value on discouraging production usage of unstable surfaces (this goal is itself controversial, because developers might not want to commit to a stable surface too early, or there is just some subtle codegen toggle which is infeasible to have a driver option). Therefore, I suggest we drop the diagnostic, at least before the diagnostic gets sufficiently better support for the overridding needs. Removing the error is a degraded error checking experience. I think this error checking behavior, if desirable, should be enabled explicitly by tools. Users preferring the behavior can figure out a way to do so. Reviewed By: jhenderson, rnk Differential Revision: https://reviews.llvm.org/D120455
79 lines
3.2 KiB
Plaintext
79 lines
3.2 KiB
Plaintext
## This test checks that a correct static library is created.
|
|
|
|
# RUN: yaml2obj %S/Inputs/input1.yaml -o %t-input1.o
|
|
# RUN: yaml2obj %S/Inputs/input2.yaml -o %t-input2.o
|
|
# RUN: llvm-as %S/Inputs/x86_64-osx.ll -o %t-x86_64.bc
|
|
|
|
# RUN: rm -rf %t.lib %t2.lib
|
|
# RUN: llvm-libtool-darwin -static -o %t.lib %t-input1.o %t-input2.o %t-x86_64.bc
|
|
# RUN: llvm-libtool-darwin -static -o %t2.lib -o %t.lib %t-input1.o %t-input2.o %t-x86_64.bc
|
|
# RUN: not ls %t2.lib
|
|
|
|
## Check that binaries are present:
|
|
# RUN: llvm-ar t %t.lib | \
|
|
# RUN: FileCheck %s --check-prefix=CHECK-NAMES --implicit-check-not={{.}} -DPREFIX=%basename_t.tmp
|
|
|
|
# CHECK-NAMES: [[PREFIX]]-input1.o
|
|
# CHECK-NAMES-NEXT: [[PREFIX]]-input2.o
|
|
# CHECK-NAMES-NEXT: [[PREFIX]]-x86_64.bc
|
|
|
|
## Check that symbols are present:
|
|
# RUN: llvm-nm --print-armap %t.lib | \
|
|
# RUN: FileCheck %s --check-prefix=CHECK-SYMBOLS -DPREFIX=%basename_t.tmp --match-full-lines
|
|
|
|
# CHECK-SYMBOLS: Archive map
|
|
# CHECK-SYMBOLS-NEXT: _symbol1 in [[PREFIX]]-input1.o
|
|
# CHECK-SYMBOLS-NEXT: _symbol2 in [[PREFIX]]-input2.o
|
|
# CHECK-SYMBOLS-NEXT: _x86_64 in [[PREFIX]]-x86_64.bc
|
|
# CHECK-SYMBOLS-EMPTY:
|
|
|
|
## Check that output archive is in Darwin format:
|
|
# RUN: llvm-objdump --macho --archive-headers %t.lib | \
|
|
# RUN: FileCheck %s --check-prefix=FORMAT -DPREFIX=%basename_t.tmp -DARCHIVE=%t
|
|
|
|
# FORMAT: Archive : [[ARCHIVE]]
|
|
# FORMAT-NEXT: __.SYMDEF
|
|
# FORMAT-NEXT: [[PREFIX]]-input1.o
|
|
# FORMAT-NEXT: [[PREFIX]]-input2.o
|
|
# FORMAT-NEXT: [[PREFIX]]-x86_64.bc
|
|
# FORMAT-NOT: {{.}}
|
|
|
|
## Check that the output file is overwritten:
|
|
# RUN: llvm-libtool-darwin -static -o %t.lib %t-input2.o
|
|
# RUN: llvm-ar t %t.lib | \
|
|
# RUN: FileCheck %s --check-prefix=OVERWRITE-NAMES --implicit-check-not={{.}} -DPREFIX=%basename_t.tmp
|
|
# RUN: llvm-nm --print-armap %t.lib | \
|
|
# RUN: FileCheck %s --check-prefix=OVERWRITE-SYMBOLS -DPREFIX=%basename_t.tmp --match-full-lines
|
|
|
|
# OVERWRITE-NAMES: [[PREFIX]]-input2.o
|
|
|
|
# OVERWRITE-SYMBOLS: Archive map
|
|
# OVERWRITE-SYMBOLS-NEXT: _symbol2 in [[PREFIX]]-input2.o
|
|
# OVERWRITE-SYMBOLS-EMPTY:
|
|
|
|
## Duplicate a binary:
|
|
# RUN: llvm-libtool-darwin -static -o %t.lib %t-input1.o %t-input2.o %t-input1.o 2>&1 | \
|
|
# RUN: FileCheck %s --check-prefix=DUPLICATE-INPUT -DFILE=%basename_t.tmp-input1.o \
|
|
# RUN: -DINPUTA=%t-input1.o -DINPUTB=%t-input1.o
|
|
|
|
# DUPLICATE-INPUT: warning: file '[[FILE]]' was specified multiple times.
|
|
# DUPLICATE-INPUT-DAG: [[INPUTA]]
|
|
# DUPLICATE-INPUT-DAG: [[INPUTB]]
|
|
|
|
# RUN: not llvm-libtool-darwin -warnings_as_errors -static -o %t.lib %t-input1.o %t-input2.o %t-input1.o 2>&1 | \
|
|
# RUN: FileCheck %s --check-prefix=ERROR-DUPLICATE-INPUT -DFILE=%basename_t.tmp-input1.o \
|
|
# RUN: -DINPUTA=%t-input1.o -DINPUTB=%t-input1.o
|
|
|
|
# ERROR-DUPLICATE-INPUT: error: file '[[FILE]]' was specified multiple times.
|
|
# ERROR-DUPLICATE-INPUT-DAG: [[INPUTA]]
|
|
# ERROR-DUPLICATE-INPUT-DAG: [[INPUTB]]
|
|
|
|
## Make sure we can combine object files with the same name if
|
|
## they are for different architectures.
|
|
# RUN: mkdir -p %t/arm64 %t/armv7
|
|
# RUN: llvm-as %S/Inputs/arm64-ios.ll -o %t/arm64/out.bc
|
|
# RUN: llvm-as %S/Inputs/armv7-ios.ll -o %t/armv7/out.bc
|
|
## Command output should be empty.
|
|
# RUN: llvm-libtool-darwin -static %t/arm64/out.bc %t/armv7/out.bc -o %t.lib 2>&1 | \
|
|
# RUN: FileCheck %s --implicit-check-not=warning: --allow-empty
|