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
112 lines
5.2 KiB
Plaintext
112 lines
5.2 KiB
Plaintext
## This test checks that the -filelist option works correctly.
|
|
|
|
# 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
|
|
|
|
## Passing files in a listfile:
|
|
# RUN: echo %t-input1.o > %t.files.txt
|
|
# RUN: echo %t-input2.o >> %t.files.txt
|
|
# RUN: echo %t-x86_64.bc >> %t.files.txt
|
|
# RUN: llvm-libtool-darwin -static -o %t.lib -filelist %t.files.txt
|
|
|
|
## 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:
|
|
|
|
# RUN: rm -rf %t/dirname && mkdir -p %t/dirname
|
|
# RUN: yaml2obj %S/Inputs/input1.yaml -o %t/dirname/%basename_t.tmp-input1.o
|
|
# RUN: echo %basename_t.tmp-input1.o > %t.files2.txt
|
|
|
|
## Passing in dirname:
|
|
# RUN: llvm-libtool-darwin -static -o %t.lib -filelist %t.files2.txt,%t/dirname
|
|
# RUN: llvm-ar t %t.lib | \
|
|
# RUN: FileCheck %s --check-prefix=DIRNAME-NAMES --implicit-check-not={{.}} -DPREFIX=%basename_t.tmp
|
|
# RUN: llvm-nm --print-armap %t.lib | \
|
|
# RUN: FileCheck %s --check-prefix=DIRNAME-SYMBOLS -DPREFIX=%basename_t.tmp --match-full-lines
|
|
|
|
# DIRNAME-NAMES: [[PREFIX]]-input1.o
|
|
|
|
# DIRNAME-SYMBOLS: Archive map
|
|
# DIRNAME-SYMBOLS-NEXT: _symbol1 in [[PREFIX]]-input1.o
|
|
# DIRNAME-SYMBOLS-EMPTY:
|
|
|
|
## Passing both -filelist option and object file as input:
|
|
# RUN: llvm-libtool-darwin -static -o %t.lib -filelist %t.files2.txt,%t/dirname %t-input2.o
|
|
# RUN: llvm-ar t %t.lib | \
|
|
# RUN: FileCheck %s --check-prefix=REVERSE-NAMES --implicit-check-not={{.}} -DPREFIX=%basename_t.tmp
|
|
# RUN: llvm-nm --print-armap %t.lib | \
|
|
# RUN: FileCheck %s --check-prefix=REVERSE-SYMBOLS -DPREFIX=%basename_t.tmp --match-full-lines
|
|
|
|
# REVERSE-NAMES: [[PREFIX]]-input2.o
|
|
# REVERSE-NAMES-NEXT: [[PREFIX]]-input1.o
|
|
|
|
# REVERSE-SYMBOLS: Archive map
|
|
# REVERSE-SYMBOLS-NEXT: _symbol2 in [[PREFIX]]-input2.o
|
|
# REVERSE-SYMBOLS-NEXT: _symbol1 in [[PREFIX]]-input1.o
|
|
# REVERSE-SYMBOLS-EMPTY:
|
|
|
|
## Check that an error is thrown when a file in the filelist doesn't exist in the cwd and no dirname is specified:
|
|
# RUN: echo 'no-such-file' > %t.invalid-list.txt
|
|
# RUN: not llvm-libtool-darwin -static -o %t.lib -filelist %t.invalid-list.txt 2>&1 | \
|
|
# RUN: FileCheck %s --check-prefix=FILE-ERROR -DFILE=no-such-file -DMSG=%errc_ENOENT
|
|
|
|
# FILE-ERROR: error: '[[FILE]]': [[MSG]]
|
|
|
|
## Check that an error is thrown when the directory exists but does not contain the requested file:
|
|
# RUN: not llvm-libtool-darwin -static -o %t.lib -filelist %t.invalid-list.txt,%t/dirname 2>&1 | \
|
|
# RUN: FileCheck %s --check-prefix=DIR-ERROR -DDIR=%t/dirname -DFILE=no-such-file -DMSG=%errc_ENOENT
|
|
|
|
# DIR-ERROR: error: '[[DIR]]{{[/\\]}}[[FILE]]': [[MSG]]
|
|
|
|
## Check that an error is thrown when a file is in the cwd but dirname is specified:
|
|
# RUN: yaml2obj %S/Inputs/input2.yaml -o %basename_t.tmp-input2.o
|
|
# RUN: echo %basename_t.tmp-input2.o > %t.files-cwd.txt
|
|
# RUN: not llvm-libtool-darwin -static -o %t.lib -filelist %t.files-cwd.txt,%t/dirname 2>&1 | \
|
|
# RUN: FileCheck %s --check-prefix=DIR-ERROR -DDIR=%t/dirname -DFILE=%basename_t.tmp-input2.o -DMSG=%errc_ENOENT
|
|
|
|
## Check that an error is thrown when the directory doesn't exist:
|
|
# RUN: not llvm-libtool-darwin -static -o %t.lib -filelist %t.files-cwd.txt,%t/Invalid-Dir 2>&1 | \
|
|
# RUN: FileCheck %s --check-prefix=DIR-ERROR -DDIR=%t/Invalid-Dir -DFILE=%basename_t.tmp-input2.o -DMSG=%errc_ENOENT
|
|
|
|
## Check that an error is thrown when the filelist is empty:
|
|
# RUN: touch %t.empty-list
|
|
# RUN: not llvm-libtool-darwin -static -o %t.lib -filelist %t.empty-list 2>&1 | \
|
|
# RUN: FileCheck %s --check-prefix=EMPTY-ERROR -DFILE=%t.empty-list
|
|
|
|
# EMPTY-ERROR: error: file list file: '[[FILE]]' is empty
|
|
|
|
## Check that an error is thrown when the filelist contains a blank line:
|
|
# RUN: echo %t-input2.o > %t.blank-line.txt
|
|
# RUN: echo '' >> %t.blank-line.txt
|
|
# RUN: not llvm-libtool-darwin -static -o %t.lib -filelist %t.blank-line.txt 2>&1 | \
|
|
# RUN: FileCheck %s --check-prefix=EMPTY-FILENAME -DFILE=%t.blank-line.txt
|
|
|
|
# EMPTY-FILENAME: error: file list file: '[[FILE]]': filename cannot be empty
|
|
|
|
## Check that an error is thrown when the filelist contains a line with only spaces:
|
|
# RUN: echo %t-input2.o > %t.space-line.txt
|
|
# RUN: echo " " >> %t.space-line.txt
|
|
# RUN: not llvm-libtool-darwin -static -o %t.lib -filelist %t.space-line.txt 2>&1 | \
|
|
# RUN: FileCheck %s --check-prefix=FILE-ERROR -DFILE=' ' -DMSG=%errc_ENOENT --strict-whitespace
|
|
|
|
## Filelist option specified more than once:
|
|
# RUN: touch %t.list1.txt and %t.list2.txt
|
|
# RUN: llvm-libtool-darwin -static -o %t.lib -filelist %t.empty-list -filelist %t.files.txt 2>&1
|
|
# RUN: llvm-ar t %t.lib | \
|
|
# RUN: FileCheck %s --check-prefix=CHECK-NAMES --implicit-check-not={{.}} -DPREFIX=%basename_t.tmp
|