Wie kann verhindert werden, dass die Support CommandLine von LLVM Bibliotheksargumente verliert?C++

Programme in C++. Entwicklerforum
Anonymous
 Wie kann verhindert werden, dass die Support CommandLine von LLVM Bibliotheksargumente verliert?

Post by Anonymous »

Ich habe an einem Compiler für eine meiner Sprachen gearbeitet und wollte die Befehlszeile der LLVM-Unterstützungsbibliothek verwenden, um die Argumentanalyse durchzuführen.

Ich habe nur zwei einfache Deklarationen hinzugefügt:

Code: Select all

static cl::opt
OutputFilename("o", cl::desc("Output filename"), cl::value_desc("filename"));

static cl::list
InputFilenames("i", cl::desc("Input files"), cl::value_desc("filenames"), cl::OneOrMore);
Ich füge dann den üblichen Aufruf in main hinzu:

Code: Select all

int main(int argc, char *argv[])
{
cl::ParseCommandLineOptions(argc, argv, " My compiler\n");

...
Das Problem wird sehr deutlich, wenn ich -help an mein Programm übergebe:

Code: Select all

General options:

-aarch64-neon-syntax             - Choose style of NEON code to emit from AArch64 backend:
=generic                       -   Emit generic NEON assembly
=apple                         -   Emit Apple-style NEON assembly
-cppfname=        - Specify the name of the generated function
-cppfor=                 - Specify the name of the thing to generate
-cppgen                          - Choose what kind of output to generate
=program                       -   Generate a complete program
=module                        -   Generate a module definition
=contents                      -   Generate contents of a module
=function                      -   Generate a function definition
=functions                     -   Generate all function definitions
=inline                        -   Generate an inline function
=variable                      -   Generate a variable definition
=type                          -   Generate a type definition
-debugger-tune                   - Tune debug info for a particular debugger
=gdb                           -   gdb
=lldb                          -   lldb
=sce                           -   SCE targets (e.g. PS4)
-disable-spill-fusing            - Disable fusing of spill code into instructions
-enable-implicit-null-checks     - Fold null checks into faulting memory operations
-enable-load-pre                 -
-enable-objc-arc-opts            - enable/disable all ARC Optimizations
-enable-scoped-noalias           -
-enable-tbaa                     -
-exhaustive-register-search      - Exhaustive Search for registers bypassing the depth and interference cutoffs of last chance recoloring
-gpsize=                   - Global Pointer Addressing Size.   The default size is 8.
-i=                   - Input files
-imp-null-check-page-size= - The page size of the target in bytes
-join-liveintervals              - Coalesce copies (default=true)
-limit-float-precision=    - Generate low-precision inline sequences for some float libcalls
-merror-missing-parenthesis      - Error for missing parenthesis around predicate registers
-merror-noncontigious-register   - Error for register names that aren't contigious
-mfuture-regs                    - Enable future registers
-mips16-constant-islands         - Enable mips16 constant islands.
-mips16-hard-float               - Enable mips16 hard float.
-mno-compound                    - Disable looking for compound instructions for Hexagon
-mno-ldc1-sdc1                   - Expand double precision loads and stores to their single precision counterparts
-mno-pairing                     - Disable looking for duplex instructions for Hexagon
-mwarn-missing-parenthesis       - Warn for missing parenthesis around predicate registers
-mwarn-noncontigious-register    - Warn for register names that arent contigious
-mwarn-sign-mismatch             - Warn for mismatching a signed and unsigned value
-nvptx-sched4reg                 - NVPTX Specific: schedule for register pressue
-o=                    - Output filename
-print-after-all                 - Print IR after each pass
-print-before-all                - Print IR before each pass
-print-machineinstrs=
 - Print machine instrs
-regalloc                        - Register allocator to use
=default                       -   pick register allocator based on -O option
=fast                          -   fast register allocator
=greedy                        -   greedy register allocator
=pbqp                          -   PBQP register allocator
-rewrite-map-file=     - Symbol Rewrite Map
-rng-seed=                 - Seed for the random number generator
-stackmap-version=          - Specify the stackmap encoding version (default = 1)
-stats                           - Enable statistics output from program (available with Asserts)
-time-passes                     - Time each pass, printing elapsed time for each on exit
-verify-debug-info               -
-verify-dom-info                 - Verify dominator info (time consuming)
-verify-loop-info                - Verify loop info (time consuming)
-verify-regalloc                 - Verify during register allocation
-verify-region-info              - Verify region info (time consuming)
-verify-scev                     - Verify ScalarEvolution's backedge taken counts (slow)
-x86-asm-syntax                  - Choose style of code to emit from X86 backend:
=att                           -   Emit AT&T-style assembly
=intel                         -   Emit Intel-style assembly

Generic Options:

-help                            - Display available options (-help-hidden for more)
-help-list                       - Display list of available options (-help-list-hidden for more)
-version                         - Display the version of this program
Ich möchte natürlich den Lärm reduzieren, um nur die relevanten Befehlszeilenoptionen anzuzeigen, die ich verfügbar gemacht habe.

Mir ist klar, dass das CommandLine-Dienstprogramm globale Variablen und Vorlagenmetaprogrammierung verwendet und mein Problem wahrscheinlich auf die statische Verknüpfung mit LLVM zurückzuführen ist.

Ich habe mehrere Links gefunden, die das Problem zu berühren scheinen, aber nichts Konkretes als Lösung außer möglicherweise einer dynamischen Verknüpfung LLVM.


  • LLVM-Befehlszeile: Wie werden Argumente zurückgesetzt?
  • LLVMdev: Befehlszeilenoptionen werden in Ziel-Backend-Bibliotheken eingefügt
  • Bugzilla 8860: Befehlszeilenargumentparser bietet zu viele Optionen beim Erstellen mit --enable-shared


Ich verwende OS X El Capitan Version 10.11.1

Ich habe llvm wie folgt installiert:

Code: Select all

git clone http://llvm.org/git/llvm.git
git clone http://llvm.org/git/clang.git llvm/tools/clang
git clone http://llvm.org/git/clang-tools-extra.git llvm/tools/clang/tools/extra
git clone http://llvm.org/git/compiler-rt.git llvm/projects/compiler-rt
git clone http://llvm.org/git/libcxx.git llvm/projects/libcxx
git clone http://llvm.org/git/libcxxabi.git llvm/projects/libcxxabi

mkdir build_llvm
cd build_llvm &&  cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=prefix=/usr/local/llvm ../llvm
make
Die relevanten Teile meines Makefiles:

Code: Select all

LLVMCONFIG = llvm-config
CPPFLAGS = `$(LLVMCONFIG) --cxxflags` -std=c++11
LDFLAGS = `$(LLVMCONFIG) --ldflags` -lpthread -ldl -lz -lncurses -rdynamic
LIBS = `$(LLVMCONFIG) --libs`

%.o: %.cpp
clang++ -I /usr/local/llvm/include -c $(CPPFLAGS) $< -o $@

mycompiler: $(OBJECTS)
clang++ -I /usr/local/llvm/include -g $^ $(LIBS) $(LDFLAGS) -o $@

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post