[llvm-dev] Cannot build Clang/LLVM on Windows with LLVM_BUILD_LLVM_DYLIB

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[llvm-dev] Cannot build Clang/LLVM on Windows with LLVM_BUILD_LLVM_DYLIB

Gerolf Hoflehner via llvm-dev
I am trying to build Clang/LLVM with -DLLVM_BUILD_LLVM_DYLIB=ON and
-DLLVM_LINK_LLVM_DYLIB=ON to reduce the size of toolchain.

I am getting LINK error 1181 about `lib\LLVM.lib` not found. After
investigating, `lib\LLVM.lib` is supposed to be produced along with
`bin\LLVM.dll`. `bin\LLVM.dll` is indeed produced, but it does not
contain any exported symbols (10KB only) because LLVM does not use
`__declspec(dllexport)` and `__declspec(dllimport)`, so lib.exe
refuses to produce `lib\LLVM.lib`.

If I just build static-linked Clang/LLVM (default), it works fine.

Windows bot of WebAssembly waterfall is also affected:
https://github.com/WebAssembly/waterfall/commit/2051fd4cdb2b4017e66dfcd70203d40f3d0b461d

Compiler: Visual Studio 2017

CMake configuration:

cmake -GNinja -Bbuild -Hllvm -DCMAKE_BUILD_TYPE=Release
-DLLVM_INCLUDE_EXAMPLES=OFF
-DLLVM_INCLUDE_TESTS=OFF
-DCMAKE_INSTALL_PREFIX=d:\a\1\b
-DLLVM_TARGETS_TO_BUILD=X86
-DLLVM_INSTALL_TOOLCHAIN_ONLY=ON
-DLLVM_BUILD_LLVM_DYLIB=ON
-DLLVM_LINK_LLVM_DYLIB=ON
-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly
_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [llvm-dev] Cannot build Clang/LLVM on Windows with LLVM_BUILD_LLVM_DYLIB

Gerolf Hoflehner via llvm-dev
It's unsupported on MS toolchain. It's too hard to make LLVM headers and libs DLL-ready.
It would be theoretically possible on mingw. (oops, it requires awk...) 

On Fri, Jun 9, 2017 at 5:25 PM biologi spm via llvm-dev <[hidden email]> wrote:
I am trying to build Clang/LLVM with -DLLVM_BUILD_LLVM_DYLIB=ON and
-DLLVM_LINK_LLVM_DYLIB=ON to reduce the size of toolchain.

I am getting LINK error 1181 about `lib\LLVM.lib` not found. After
investigating, `lib\LLVM.lib` is supposed to be produced along with
`bin\LLVM.dll`. `bin\LLVM.dll` is indeed produced, but it does not
contain any exported symbols (10KB only) because LLVM does not use
`__declspec(dllexport)` and `__declspec(dllimport)`, so lib.exe
refuses to produce `lib\LLVM.lib`.

If I just build static-linked Clang/LLVM (default), it works fine.

Windows bot of WebAssembly waterfall is also affected:
https://github.com/WebAssembly/waterfall/commit/2051fd4cdb2b4017e66dfcd70203d40f3d0b461d

Compiler: Visual Studio 2017

CMake configuration:

cmake -GNinja -Bbuild -Hllvm -DCMAKE_BUILD_TYPE=Release
-DLLVM_INCLUDE_EXAMPLES=OFF
-DLLVM_INCLUDE_TESTS=OFF
-DCMAKE_INSTALL_PREFIX=d:\a\1\b
-DLLVM_TARGETS_TO_BUILD=X86
-DLLVM_INSTALL_TOOLCHAIN_ONLY=ON
-DLLVM_BUILD_LLVM_DYLIB=ON
-DLLVM_LINK_LLVM_DYLIB=ON
-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly
_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev

_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [llvm-dev] Cannot build Clang/LLVM on Windows with LLVM_BUILD_LLVM_DYLIB

Gerolf Hoflehner via llvm-dev
@Nakamura
Well it is unsupported, because noone added a script to generate the required DEF-File(since it seems noone wants to use export definitions).
Somewhere i have a batchscript that does just that and(in theory therefore) even runs from cmake(in the cmake files there is only a script for Mac iirc and none for Windows).
Maybe i can find it and someone with cmake expertise can add it to the scripts/proper buildstages

2017-06-09 11:59 GMT+02:00 NAKAMURA Takumi via llvm-dev <[hidden email]>:
It's unsupported on MS toolchain. It's too hard to make LLVM headers and libs DLL-ready.
It would be theoretically possible on mingw. (oops, it requires awk...) 

On Fri, Jun 9, 2017 at 5:25 PM biologi spm via llvm-dev <[hidden email]> wrote:
I am trying to build Clang/LLVM with -DLLVM_BUILD_LLVM_DYLIB=ON and
-DLLVM_LINK_LLVM_DYLIB=ON to reduce the size of toolchain.

I am getting LINK error 1181 about `lib\LLVM.lib` not found. After
investigating, `lib\LLVM.lib` is supposed to be produced along with
`bin\LLVM.dll`. `bin\LLVM.dll` is indeed produced, but it does not
contain any exported symbols (10KB only) because LLVM does not use
`__declspec(dllexport)` and `__declspec(dllimport)`, so lib.exe
refuses to produce `lib\LLVM.lib`.

If I just build static-linked Clang/LLVM (default), it works fine.

Windows bot of WebAssembly waterfall is also affected:
https://github.com/WebAssembly/waterfall/commit/2051fd4cdb2b4017e66dfcd70203d40f3d0b461d

Compiler: Visual Studio 2017

CMake configuration:

cmake -GNinja -Bbuild -Hllvm -DCMAKE_BUILD_TYPE=Release
-DLLVM_INCLUDE_EXAMPLES=OFF
-DLLVM_INCLUDE_TESTS=OFF
-DCMAKE_INSTALL_PREFIX=d:\a\1\b
-DLLVM_TARGETS_TO_BUILD=X86
-DLLVM_INSTALL_TOOLCHAIN_ONLY=ON
-DLLVM_BUILD_LLVM_DYLIB=ON
-DLLVM_LINK_LLVM_DYLIB=ON
-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly
_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev

_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev



_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [llvm-dev] Cannot build Clang/LLVM on Windows with LLVM_BUILD_LLVM_DYLIB

Gerolf Hoflehner via llvm-dev
In reply to this post by Gerolf Hoflehner via llvm-dev
I am only interested in using Clang/LLVM.

clang.exe, clang++.exe, clang-cl.exe, clang-cl.exe and
msbuild-bin/cl.exe are each 37MB, but they serve almost the same
purpose, just receive different flavours of command flags.

By passing -v flag, I noticed that all of them will parse the command
flags, then call itself with more command flags for the main parsing
and compiling.

This is quite similar with gcc.exe, g++.exe, c++.exe and cpp.exe in
GCC, but these GCC drivers are much smaller  (each around 600KB to
900KB) and they all call another program cc1.exe or cc1plus,exe (each
around 20MB). Therefore, GCC toolchain is much smaller.

Can Clang/LLVM add a configuration similar to GCC?
_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [llvm-dev] Cannot build Clang/LLVM on Windows with LLVM_BUILD_LLVM_DYLIB

Gerolf Hoflehner via llvm-dev
On 10 June 2017 at 21:04, biologi spm via llvm-dev
<[hidden email]> wrote:
> clang.exe, clang++.exe, clang-cl.exe, clang-cl.exe and
> msbuild-bin/cl.exe are each 37MB, but they serve almost the same
> purpose, just receive different flavours of command flags.

On Unix systems these are all symlinks and so essentially free. I hear
Windows doesn't cope well with that though so it looks like we just
copy the files there.

> Can Clang/LLVM add a configuration similar to GCC?

That's probably best discussed on the cfe-dev mailing list. Doing it
optimally would involve substantial refactoring (essentially splitting
lib/Driver out into its own tool). I think you'd be lucky to get
anyone to sign up to work on that, but you might be able to convince
them patches are welcome.

Cheers.

Tim.
_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [llvm-dev] Cannot build Clang/LLVM on Windows with LLVM_BUILD_LLVM_DYLIB

Gerolf Hoflehner via llvm-dev
In reply to this post by Gerolf Hoflehner via llvm-dev
On Sun, Jun 11, 2017 at 12:04:25PM +0800, biologi spm via llvm-dev wrote:
> This is quite similar with gcc.exe, g++.exe, c++.exe and cpp.exe in
> GCC, but these GCC drivers are much smaller  (each around 600KB to
> 900KB) and they all call another program cc1.exe or cc1plus,exe (each
> around 20MB). Therefore, GCC toolchain is much smaller.
>
> Can Clang/LLVM add a configuration similar to GCC?

You should be able to replace clang++.exe and clang-cpp.exe with a
trivial program that uses execvp with clang.exe as file and argv as
given to the program.

Joerg
_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [llvm-dev] Cannot build Clang/LLVM on Windows with LLVM_BUILD_LLVM_DYLIB

Gerolf Hoflehner via llvm-dev
In reply to this post by Gerolf Hoflehner via llvm-dev
In the end I just deleted clang-cl.exe etc and create real Windows
symlink with "mklink clang-cl.exe clang.exe" (required administrator
permission). Works perfectly. Apparently these drivers inspect their
own name argv[0] before deciding what mode to run.

With this hack and ninja -C build install-clang install-clang-headers,
the resulting toolset is only 44MB, which is a great improvement when
compared with the default installation (380+MB).

Thanks for pointing out that these drivers are just symlinks!

On Sun, Jun 11, 2017 at 10:29 PM, Tim Northover <[hidden email]> wrote:

> On 10 June 2017 at 21:04, biologi spm via llvm-dev
> <[hidden email]> wrote:
>> clang.exe, clang++.exe, clang-cl.exe, clang-cl.exe and
>> msbuild-bin/cl.exe are each 37MB, but they serve almost the same
>> purpose, just receive different flavours of command flags.
>
> On Unix systems these are all symlinks and so essentially free. I hear
> Windows doesn't cope well with that though so it looks like we just
> copy the files there.
>
>> Can Clang/LLVM add a configuration similar to GCC?
>
> That's probably best discussed on the cfe-dev mailing list. Doing it
> optimally would involve substantial refactoring (essentially splitting
> lib/Driver out into its own tool). I think you'd be lucky to get
> anyone to sign up to work on that, but you might be able to convince
> them patches are welcome.
>
> Cheers.
>
> Tim.
_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [llvm-dev] Cannot build Clang/LLVM on Windows with LLVM_BUILD_LLVM_DYLIB

Gerolf Hoflehner via llvm-dev
For what it's worth, Windows 10 Creators Update (version 1703) and up allow you
to create symbolic links without elevation if you've enabled developer mode.

On 6/11/17, 10:07 PM, "llvm-dev on behalf of biologi spm via llvm-dev" <[hidden email] on behalf of [hidden email]> wrote:

    In the end I just deleted clang-cl.exe etc and create real Windows
    symlink with "mklink clang-cl.exe clang.exe" (required administrator
    permission). Works perfectly. Apparently these drivers inspect their
    own name argv[0] before deciding what mode to run.
   
    With this hack and ninja -C build install-clang install-clang-headers,
    the resulting toolset is only 44MB, which is a great improvement when
    compared with the default installation (380+MB).
   
    Thanks for pointing out that these drivers are just symlinks!
   
    On Sun, Jun 11, 2017 at 10:29 PM, Tim Northover <[hidden email]> wrote:
    > On 10 June 2017 at 21:04, biologi spm via llvm-dev
    > <[hidden email]> wrote:
    >> clang.exe, clang++.exe, clang-cl.exe, clang-cl.exe and
    >> msbuild-bin/cl.exe are each 37MB, but they serve almost the same
    >> purpose, just receive different flavours of command flags.
    >
    > On Unix systems these are all symlinks and so essentially free. I hear
    > Windows doesn't cope well with that though so it looks like we just
    > copy the files there.
    >
    >> Can Clang/LLVM add a configuration similar to GCC?
    >
    > That's probably best discussed on the cfe-dev mailing list. Doing it
    > optimally would involve substantial refactoring (essentially splitting
    > lib/Driver out into its own tool). I think you'd be lucky to get
    > anyone to sign up to work on that, but you might be able to convince
    > them patches are welcome.
    >
    > Cheers.
    >
    > Tim.
    _______________________________________________
    LLVM Developers mailing list
    [hidden email]
    https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.llvm.org_cgi-2Dbin_mailman_listinfo_llvm-2Ddev&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=0LIvfW5mUdT3ZmIPfwn0Aa2xlN0lu6RLOxyxDOrxmYY&s=iXZxWlDU8eX3QDP5eLAFLS_m0rTzRZbKo6dIXKvyQqQ&e= 
   

_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Loading...