Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update LDC compiler class #86

Closed
mleise opened this issue Jul 1, 2013 · 6 comments
Closed

Update LDC compiler class #86

mleise opened this issue Jul 1, 2013 · 6 comments

Comments

@mleise
Copy link

mleise commented Jul 1, 2013

The compiler installs as ldc2 nowadays and some of the flags need to be adapted, like
-[enable/disable]-inlining

@s-ludwig
Copy link
Member

s-ludwig commented Jul 1, 2013

I'll fix the inline flag. Do you have any other concrete examples that need work? I'll need some time until I can build and test with the latest LDC.

The "ldc2" binary name should be fine, though. Just run with "dub --compiler=ldc2". I'll make it clear in the command line help that arbitrary prefixes/suffixes to the compiler name are supported.

@mleise
Copy link
Author

mleise commented Jul 1, 2013

I tried that, but assumed --compiler==ldc2 would use some default. No I have no other examples at the moment. I could dump the command-line help output. Then again this can probably wait. The -inline switch was actually stopping 'simple' release builds with ldc from working.

@mleise
Copy link
Author

mleise commented Jul 1, 2013

GitHub will survive it. See if you use any of the flags incorrectly... -d-version and -d-debug ? deprectation warning flags?
Looks like inlining is enabled by default at -O2

OPTIONS:
  -D                                           - Generate documentation
  -Dd=<docdir>                                 - Write documentation file to <docdir> directory
  -Df=<filename>                               - Write documentation file to <filename>
  -H                                           - Generate 'header' file
  -Hd=<hdrdir>                                 - Write 'header' file to <hdrdir> directory
  -Hf=<filename>                               - Write 'header' file to <filename>
  -Hkeep-all-bodies                            - Keep all function bodies in .di files
  -I=<path>                                    - Where to look for imports
  -J=<path>                                    - Where to look for string imports
  -L=<linkerflag>                              - Pass <linkerflag> to the linker
  Setting the optimization level:
    -O                                         - Equivalent to -O3
    -O0                                        - No optimizations (default)
    -O1                                        - Simple optimizations
    -O2                                        - Good optimizations
    -O3                                        - Aggressive optimizations
    -O4                                        - Link-time optimization
    -O5                                        - Link-time optimization
    -Os                                        - Like -O2 with extra optimizations for size
    -Oz                                        - Like -Os but reduces code size further
  -X                                           - generate JSON file
  -Xf=<filename>                               - write JSON file to <filename>
  -asm-verbose                                 - Add comments to directives.
  -bounds-checking-single-trap                 - Use one trap block per function
  -c                                           - Do not link
  -check-printf-calls                          - Validate printf call format strings against arguments
  -code-model                                  - Code model
    =default                                   -   Target default code model
    =small                                     -   Small code model
    =kernel                                    -   Kernel code model
    =medium                                    -   Medium code model
    =large                                     -   Large code model
  -cppfname=<function name>                    - Specify the name of the generated function
  -cppfor=<string>                             - 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
  Allow deprecated code/language features:
    -de                                        - Do not allow deprecated features
    -d                                         - Silently allow deprecated features
    -dw                                        - Warn about the use of deprecated features
  -d-debug=<level/idents>                      - Compile in debug code >= <level> or identified by <idents>.
  -d-version=<level/idents>                    - Compile in version code >= <level> or identified by <idents>
  -debuglib=<lib,...>                          - Set default libraries for debug build
  -defaultlib=<lib,...>                        - Set default libraries for non-debug build
  -deps=<filename>                             - Write module dependencies to filename
  -enable-asserts                              - (*) Enable assertions
  -enable-boundscheck                          - (*) Enable array bounds checks
  -disable-d-passes                            - Disable all D-specific passes
  -disable-gc2stack                            - Disable promotion of GC allocations to stack memory
  -enable-preconditions                        - (*) Enable function preconditions
  -disable-red-zone                            - Do not emit code that uses the red zone.
  -disable-simplify-drtcalls                   - Disable simplification of druntime calls
  -disable-simplify-libcalls                   - Disable simplification of well-known C runtime calls
  -disable-spill-fusing                        - Disable fusing of spill code into instructions
  -enable-contracts                            - (*) Enable function pre- and post-conditions
  -enable-correct-eh-support                   - Make the -lowerinvoke pass insert expensive, but correct, EH code
  -enable-inlining                             - Enable function inlining (default in -O2 and higher)
  -enable-invariants                           - (*) Enable invariants
  -enable-load-pre                             - 
  -enable-objc-arc-opts                        - enable/disable all ARC Optimizations
  -enable-postconditions                       - (*) Enable function postconditions
  -enable-tbaa                                 - 
  -fatal-assembler-warnings                    - Consider warnings as error
  -fdata-sections                              - Emit data into separate sections
  -ffunction-sections                          - Emit functions into separate sections
  Generating debug information:
    -g                                         - Generate debug information
    -gc                                        - Same as -g, but pretend to be C
  -help                                        - Display available options (-help-hidden for more)
  -ignore                                      - Ignore unsupported pragmas
  -internalize-public-api-file=<filename>      - A file containing list of symbol names to preserve
  -internalize-public-api-list=<list>          - A list of symbol names to preserve
  -join-liveintervals                          - Coalesce copies (default=true)
  -lib                                         - Create static library
  -limit-float-precision=<uint>                - Generate low-precision inline sequences for some float libcalls
  -linkonce-templates                          - Use linkonce_odr linkage for template symbols instead of weak_odr
  -m32                                         - 32 bit target
  -m64                                         - 64 bit target
  -main                                        - add empty main() (e.g. for unittesting)
  -march=<string>                              - Architecture to generate code for:
  -mattr=<a1,+a2,-a3,...>                      - Target specific attributes (-mattr=help for details)
  -mc-x86-disable-arith-relaxation             - Disable relaxation of arithmetic instruction for X86
  -mcpu=<cpu-name>                             - Target a specific cpu type (-mcpu=help for details)
  -mtriple=<string>                            - Override target triple
  -noasm                                       - Disallow use of inline assembler
  -nodefaultlib                                - Don't add a default library for linking implicitly
  -noruntime                                   - Do not allow code that generates implicit runtime calls
  -o-                                          - Do not write object file
  -od=<objdir>                                 - Write object files to directory <objdir>
  -of=<filename>                               - Use <filename> as output file name
  -op                                          - Do not strip paths from source file
  -oq                                          - Write object files with fully qualified names
  -output-bc                                   - Write LLVM bitcode
  -output-ll                                   - Write LLVM IR
  -output-o                                    - Write native object
  -output-s                                    - Write native assembly
  -pre-RA-sched                                - Instruction schedulers available (before register allocation):
    =default                                   -   Best scheduler for the target
    =list-burr                                 -   Bottom-up register reduction list scheduling
    =source                                    -   Similar to list-burr but schedules in source order when possible
    =list-hybrid                               -   Bottom-up register pressure aware list scheduling which tries to balance latency and register pressure
    =list-ilp                                  -   Bottom-up register pressure aware list scheduling which tries to balance ILP and register pressure
    =vliw-td                                   -   VLIW scheduler
  -print-after-all                             - Print IR after each pass
  -print-before-all                            - Print IR before each pass
  -print-machineinstrs=<pass-name>             - Print machine instrs
  -profile-estimator-loop-weight=<loop-weight> - Number of loop executions used for profile-estimator
  -profile-file=<filename>                     - Profile file loaded by -profile-metadata-loader
  -profile-info-file=<filename>                - Profile file loaded by -profile-loader
  -profile-verifier-noassert                   - Disable assertions
  -property                                    - Enforce property syntax
  -regalloc                                    - Register allocator to use
    =default                                   -   pick register allocator based on -O option
    =fast                                      -   fast register allocator
    =greedy                                    -   greedy register allocator
  -release                                     - Disables asserts, invariants, contracts and boundscheck
  -relocation-model                            - Relocation model
    =default                                   -   Target default relocation model
    =static                                    -   Non-relocatable code
    =pic                                       -   Fully relocatable, position independent code
    =dynamic-no-pic                            -   Relocatable external references, non-relocatable code
  -run=<string>                                - program args...
  -shared                                      - Create shared library
  -shrink-wrap                                 - Shrink wrap callee-saved register spills/restores
  -singleobj                                   - Create only a single output object file
  -spiller                                     - Spiller to use: (default: standard)
    =trivial                                   -   trivial spiller
    =inline                                    -   inline spiller
  -strip-debug                                 - Strip symbolic debug information before optimization
  -struct-path-tbaa                            - 
  -time-passes                                 - Time each pass, printing elapsed time for each on exit
  -unit-at-a-time                              - Enable basic IPO
  -unittest                                    - Compile in unit tests
  -v                                           - Verbose
  -v-cg                                        - Verbose codegen
  -vectorize-loops                             - Run the Loop vectorization passes
  -vectorize-slp                               - Run the SLP vectorization passes
  -vectorize-slp-aggressive                    - Run the BB vectorization passes
  -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)
  -version                                     - Display the version of this program
  -vv                                          - Very verbose
  Warnings:
    -w                                         - Enable warnings
    -wi                                        - Enable informational warnings
  -x86-asm-syntax                              - Choose style of code to emit from X86 backend:
    =att                                       -   Emit AT&T-style assembly
    =intel                                     -   Emit Intel-style assembly
  -x86-early-ifcvt                             - Enable early if-conversion on X86
  -x86-use-vzeroupper                          - Minimize AVX to SSE transition penalty

@s-ludwig
Copy link
Member

s-ludwig commented Jul 2, 2013

Thanks. I've added cases for the ones I could find. Leaving this open for confirmation.

@mleise
Copy link
Author

mleise commented Jul 2, 2013

Not quite there yet. For some reason the build process breaks when invoking the compiler. The relevant part of the output is:

Running ldc2...
ldc2 -w -release -O -enable-inlining -of/tmp/dub/3738160016/fast -oq -od=.dub/obj -d-version=Have_fast -d-version=benchmark -I/home/marco/Entwicklung/D/fast/source source/fast/internal.d source/fast/uniconv.d source/fast/string.d source/std/simd.d
Error: unrecognized file extension d"

Error: Build command failed with exit code 1

Full exception: object.Exception@source/dub/generators/build.d(133): Build command failed with exit code 1

When I run this line manually it works. Do you print the command verbatim?

@s-ludwig
Copy link
Member

Sorry, I lost track of this ticket. The command line is passed via a @responsefile, so there may be something hidden - although nothing really looks suspicious...

The response file is generated in the "targetPath" directory and deleted when the compiler process has exited (generators/build.d line 107). You could try to comment out that line and see what is wrong in ".dmd-response-file.txt". Anyway, I'll eventually test with LDC myself but I still have to finish a couple of other things beforehand.

s-ludwig added a commit that referenced this issue Sep 25, 2013
…d only quote arguments if needed.

LDC seems to dislike quotes in response files (errors out with: Error: unrecognized file extension d"). Now at least builds with no spaces should work fine. See also #86.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants