MoritzMaxeiner/llvm-d

Build frozen in release mode

LunaTheFoxgirl opened this issue · 9 comments

In release mode the build freezes and over time uses more and more memory (over 2 GB before i stopped it). Is that normal?

If you enabled dynamic loading that's likely a consequence of the CTFE engine in the compiler frontend, which doesn't collect any memory iirc. Without dynamic loading there's nothing in llvm-d that should cause this.

Is there a way for the code to be optimized on the llvm-d end to use less CTFE, to not cause compilation issues on release mode?

Or should I build the release binaries on a more powerful machine?

Is there a way for the code to be optimized on the llvm-d end to use less CTFE, to not cause compilation issues on release mode?

Don't use dynamic loading. There's no CTFE when you're using dynamic/static linking instead.

Okay, thanks for the info. :)

Reopening this because I thought of something, why doesn't the freeze happen in debug mode? Is there some extra optimizations that cause the build to take so much longer on release mode?

(for reference, in debug mode it builds llvm-d (dynamic load) pretty much instantly)

That's something you'd need to ask the authors of whatever D compiler you're using (who're likely going to ask you to reduce the problem to a minimal working example). Other than the debug block here I don't recall any difference in llvm-d w.r.t. debug vs. release code.

I will investigate this and report back to you if I find anything useful.

Here's where it freezes in release mode (with compiler set to ldc2 for good measure)

Using dub registry url 'https://code.dlang.org/'
Refreshing local packages (refresh existing: true)...
Looking for local package map at /var/lib/dub/packages/local-packages.json
Looking for local package map at /home/clipsey/.dub/packages/local-packages.json
Try to load local package map at /home/clipsey/.dub/packages/local-packages.json
Determined package version using GIT: dllvm ~master
Note: Failed to determine version of package d-jit at .. Assuming ~master.
Determined package version using GIT: wereshift ~master
Determined package version using GIT: dllvm ~master
Determined package version using GIT: copper ~wip
Refreshing local packages (refresh existing: false)...
Looking for local package map at /var/lib/dub/packages/local-packages.json
Looking for local package map at /home/clipsey/.dub/packages/local-packages.json
Try to load local package map at /home/clipsey/.dub/packages/local-packages.json
  Found dependency copper:cucore ~wip
  Found dependency copper:cujit ~wip
    Found dependency dcontain 1.0.3
    Found dependency dllvm ~master
      Found dependency llvm-d 3.0.0
Refreshing local packages (refresh existing: false)...
Looking for local package map at /var/lib/dub/packages/local-packages.json
Looking for local package map at /home/clipsey/.dub/packages/local-packages.json
Try to load local package map at /home/clipsey/.dub/packages/local-packages.json
  Found dependency copper:cucore ~wip
  Found dependency copper:cujit ~wip
    Found dependency dcontain 1.0.3
    Found dependency dllvm ~master
      Found dependency llvm-d 3.0.0
Warning: License in subpackage copper:cucore is different than it's parent package, this is discouraged.
Warning: License in subpackage copper:cujit is different than it's parent package, this is discouraged.
Generating using build
Configuring dependent copper, deps:"copper:cucore", "copper:cujit"
  Configuring dependent copper:cucore, deps:
  Configuring dependent copper:cujit, deps:"copper:cucore", "dcontain", "dllvm"
    Configuring dependent dcontain, deps:
    Configuring dependent dllvm, deps:"llvm-d"
      Configuring dependent llvm-d, deps:
Performing "release" build using ldc2 for x86_64.
copper:cucore ~wip: target for configuration "library" is up to date.
Using existing build in /mnt/Data/copperlang/core/.dub/build/library-release-linux.posix-x86_64-ldc_2087-A8E922F3989B9C90BB82173211A2CE06/.
Copying target from /mnt/Data/copperlang/core/.dub/build/library-release-linux.posix-x86_64-ldc_2087-A8E922F3989B9C90BB82173211A2CE06/libcopper_cucore.a to /mnt/Data/copperlang/core
dcontain 1.0.3: target for configuration "library" is up to date.
Using existing build in /home/clipsey/.dub/packages/dcontain-1.0.3/dcontain/.dub/build/library-release-linux.posix-x86_64-ldc_2087-9B29CA7CEC663914DDD9DB2715C4BB21/.
Copying target from /home/clipsey/.dub/packages/dcontain-1.0.3/dcontain/.dub/build/library-release-linux.posix-x86_64-ldc_2087-9B29CA7CEC663914DDD9DB2715C4BB21/libdcontain.a to /home/clipsey/.dub/packages/dcontain-1.0.3/dcontain
Target '/home/clipsey/.dub/packages/llvm-d-3.0.0/llvm-d/.dub/build/native-target-release-linux.posix-x86_64-ldc_2087-58BCEACC346382DDC3DBAF58FE9B39C6/libllvm-d.a' doesn't exist, need rebuild.
llvm-d 3.0.0: building configuration "native-target"...
ldc2 -lib -of/home/clipsey/.dub/packages/llvm-d-3.0.0/llvm-d/.dub/build/native-target-release-linux.posix-x86_64-ldc_2087-58BCEACC346382DDC3DBAF58FE9B39C6/libllvm-d.a -release -enable-inlining -Hkeep-all-bodies -O3 -w -oq -od=.dub/obj -d-version=LLVM_Target_X86 -d-version=LLVM_Load -d-version=DEBUG -d-version=Have_llvm_d -I/home/clipsey/.dub/packages/llvm-d-3.0.0/llvm-d/source/ /home/clipsey/.dub/packages/llvm-d-3.0.0/llvm-d/source/llvm/config.d /home/clipsey/.dub/packages/llvm-d-3.0.0/llvm-d/source/llvm/constants.d /home/clipsey/.dub/packages/llvm-d-3.0.0/llvm-d/source/llvm/functions/link.d /home/clipsey/.dub/packages/llvm-d-3.0.0/llvm-d/source/llvm/functions/load.d /home/clipsey/.dub/packages/llvm-d-3.0.0/llvm-d/source/llvm/functions/package.d /home/clipsey/.dub/packages/llvm-d-3.0.0/llvm-d/source/llvm/package.d /home/clipsey/.dub/packages/llvm-d-3.0.0/llvm-d/source/llvm/types.d -vcolumns
/home/clipsey/.dub/packages/llvm-d-3.0.0/llvm-d/source/llvm/functions/load.d-mixin-134(134,8442): Deprecation: function `llvm.functions.link.LLVMSetModuleInlineAsm` is deprecated - Use LLVMSetModuleInlineAsm2 instead.
/home/clipsey/.dub/packages/llvm-d-3.0.0/llvm-d/source/llvm/functions/load.d-mixin-134(134,13392): Deprecation: function `llvm.functions.link.LLVMGetValueName` is deprecated - Use LLVMGetValueName2 instead.
/home/clipsey/.dub/packages/llvm-d-3.0.0/llvm-d/source/llvm/functions/load.d-mixin-134(134,13490): Deprecation: function `llvm.functions.link.LLVMSetValueName` is deprecated - Use LLVMSetValueName2 instead.
/home/clipsey/.dub/packages/llvm-d-3.0.0/llvm-d/source/llvm/functions/load.d-mixin-134(134,23066): Deprecation: function `llvm.functions.link.LLVMConstInlineAsm` is deprecated - Use LLVMGetInlineAsm instead.
/home/clipsey/.dub/packages/llvm-d-3.0.0/llvm-d/source/llvm/functions/load.d-mixin-134(134,23724): Deprecation: function `llvm.functions.link.LLVMHasUnnamedAddr` is deprecated - Use LLVMGetUnnamedAddress instead.
/home/clipsey/.dub/packages/llvm-d-3.0.0/llvm-d/source/llvm/functions/load.d-mixin-134(134,23834): Deprecation: function `llvm.functions.link.LLVMSetUnnamedAddr` is deprecated - Use LLVMSetUnnamedAddress instead.
/home/clipsey/.dub/packages/llvm-d-3.0.0/llvm-d/source/llvm/functions/load.d-mixin-134(134,37260): Deprecation: function `llvm.functions.link.LLVMBuildIntCast` is deprecated - Use LLVMBuildIntCast2 instead.

Attempting with --build=plain results in success, as well --build=debug (of course)

Though building with --build-mode=allAtOnce seems to solve it for release.

It seems to be a problem with how the frontends handle seperate builds?

It might be a good idea to leave that info in the readme for others that want to use dynamic loading in release mode.

It might be a good idea to leave that info in the readme for others that want to use dynamic loading in release mode.

Sure. Send a PR with what you feel is appropriate and I'll look it over.