Giter Club home page Giter Club logo

wclang's Introduction

Wclang is a tool which helps you to cross compile source code easily with clang on Linux/Unix for Windows.
Wclang is basically a wrapper for clang, which allows you to directly target Windows.
Wclang detects the target and headers automatically and adds them to the clang invocation command.

After the installation you will have "<mingw-triplet>-clang", "<mingw-triplet>-clang++" available as "compiler".

PREREQUISITES:

 A C++11 compiler for compiling the wrapper (g++ 4.6+, clang)
 clang
 mingw-w64 with its headers and libs
 cmake

INSTALLATION:

 cmake -DCMAKE_INSTALL_PREFIX=_prefix_ .
 make
 make install

EXAMPLES:

 i686-w64-mingw32-clang++ hello-world.cpp -o hello-world.exe && wine hello-world
 CC=i686-w64-mingw32-clang ./configure --host=i686-w64-mingw32

 x86_64-w64-mingw32-clang++ hello-world.cpp -o hello-world.exe && wine hello-world
 CC=x86_64-w64-mingw32-clang ./configure --host=x86_64-w64-mingw32

LISTING AVAILABLE PARAMETERS:
 i686-w64-clang -wc-help

LIMITATIONS:
 C++ exceptions do not work with clang<3.7, and in 3.7 just for 64-bit, clang>=6.0 added support for 32-bit.

KNOWN TO WORK ON:

 Linux:   Ubuntu, Debian (Wheezy*), Mint, Arch, Fedora and openSUSE.
          Other distributions may work as well, but have not been tested.
 Windows: Cygwin.

* Wheezy: important: clang-3.0 coming with wheezy is too old
  to compile the wrapper, so use g++ or get a newer clang
  from e.g.: http://llvm.org/apt.

wclang's People

Contributors

andrerh avatar aroig avatar bltb avatar crayxt avatar jl2210 avatar jwilk avatar mati865 avatar mstewartgallus avatar svost avatar tpoechtrager avatar xantares avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wclang's Issues

cannot find -lc++abi

Hi, I would like to ask for help on how to resolve this, as I'm new to this.

make[1]: Entering directory '/home/gorazd/Projects/BlockchainCommons/Windows/bc-seedtool-cli/deps/bc-ur/test'
x86_64-w64-mingw32-clang  -L/home/gorazd/Projects/BlockchainCommons/Windows/bc-seedtool-cli/sysroot/lib -lstdc++  test.o ../src/libbc-ur.a test-utils.o  -lm -lc++ -lc++abi -lgcc_s -lgcc -o test
/usr/bin/x86_64-w64-mingw32-ld: cannot find -lc++
/usr/bin/x86_64-w64-mingw32-ld: cannot find -lc++abi
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Dropping support for Debian Wheezy?

Debian Wheezy is a very old release (oldoldstable) and has lost support from the Debian team. I don't think it should necessarily be supported by this project anymore. That would also simplify things with the Clang versions needed.

What do you think?

wclang: warning: cannot find clang intrinsics directory

Title.

mingw version:

[pisto@pisto ~]$ x86_64-w64-mingw32-g++ -v
Using built-in specs.
COLLECT_GCC=/usr/bin/x86_64-w64-mingw32-g++
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-w64-mingw32/7.1.0/lto-wrapper
Target: x86_64-w64-mingw32
Configured with: ../configure --prefix=/usr --bindir=/usr/bin --includedir=/usr/include --mandir=/usr/share/man --infodir=/usr/share/info --datadir=/usr/share --build=x86_64-redhat-linux-gnu --host=x86_64-redhat-linux-gnu --with-gnu-as --with-gnu-ld --verbose --without-newlib --disable-multilib --disable-plugin --with-system-zlib --disable-nls --without-included-gettext --disable-win32-registry --enable-languages=c,c++,objc,obj-c++,fortran --with-bugurl=http://bugzilla.redhat.com/bugzilla --with-cloog --enable-threads=posix --enable-libgomp --target=x86_64-w64-mingw32 --with-sysroot=/usr/x86_64-w64-mingw32/sys-root --with-gxx-include-dir=/usr/x86_64-w64-mingw32/sys-root/mingw/include/c++
Thread model: posix
gcc version 7.1.0 20170502 (Fedora MinGW 7.1.0-1.fc26) (GCC) 

Cannot use flag -mllvm?

I use o-llvm instead of llvm
when I input command like this:
x86_64-w64-mingw32-clang test2.c -o test.exe -mllvm -fla -v
I got error:
x86_64-w64-mingw32-gcc: error: unrecognized command line option ‘-mllvm’
x86_64-w64-mingw32-gcc: error: unrecognized command line option ‘-sub’

I think you the reason is this project is based on llvm
but I really need obfuscation function,
is there any way to fix this?

Ubuntu PPA

Hello, I've created PPA for Ubuntu providing prebuild wclang releases.

To automatize it I've set up project mirroring this repository on Launchpad. Once a day it looks for new commits and builds new release if there are any. If you have Launchpad account I can give you full permissions/ownership.

I'm currently holding packaging scripts for Debian and Ubuntu on a branch of my fork but I'll have to move them to separate repository or merge it with this repository to allow automatic imports.

Decision is up to you if you want those scripts in official repository on separate branch.

[SOLVED] Error when creating object file

Here's the log for default command that links executable, it will give the following error:

$ w32-clang main.c -o main.exe
/tmp/main-420ff2.s: Assembler messages:
/tmp/main-420ff2.s:1: Error: unknown pseudo-op: `.def'
/tmp/main-420ff2.s:2: Error: unknown pseudo-op: `.scl'
/tmp/main-420ff2.s:3: Error: Missing symbol name in directive
/tmp/main-420ff2.s:4: Error: unknown pseudo-op: `.endef'
/tmp/main-420ff2.s:5: Error: expected symbol name
/tmp/main-420ff2.s:6: Error: junk at end of line, first unrecognized character is `@'
/tmp/main-420ff2.s:7: Error: unknown pseudo-op: `.def'
/tmp/main-420ff2.s:8: Error: unknown pseudo-op: `.scl'
/tmp/main-420ff2.s:9: Error: Missing symbol name in directive
/tmp/main-420ff2.s:9: Error: unrecognized symbol type "32"
/tmp/main-420ff2.s:10: Error: unknown pseudo-op: `.endef'
/tmp/main-420ff2.s:30: Error: unknown pseudo-op: `.def'
/tmp/main-420ff2.s:31: Error: unknown pseudo-op: `.scl'
/tmp/main-420ff2.s:32: Error: Missing symbol name in directive
/tmp/main-420ff2.s:32: Error: unrecognized symbol type "32"
/tmp/main-420ff2.s:33: Error: unknown pseudo-op: `.endef'
/tmp/main-420ff2.s:68: Fatal error: bad .section directive: want a,w,x,M,S,G,T in string
clang: error: assembler (via gcc) command failed with exit code 1 (use -v to see invocation)

If I enable mingw linker:

w32-clang main.c -o main.exe -wc-use-mingw-linker

All is fine! Executable is created. Now let's try to create object file:

$ w32-clang -c main.c -o main.obj
/tmp/main-7f4d85.s: Assembler messages:
/tmp/main-7f4d85.s:1: Error: unknown pseudo-op: `.def'
/tmp/main-7f4d85.s:2: Error: unknown pseudo-op: `.scl'
/tmp/main-7f4d85.s:3: Error: Missing symbol name in directive
/tmp/main-7f4d85.s:4: Error: unknown pseudo-op: `.endef'
/tmp/main-7f4d85.s:5: Error: expected symbol name
/tmp/main-7f4d85.s:6: Error: junk at end of line, first unrecognized character is `@'
/tmp/main-7f4d85.s:7: Error: unknown pseudo-op: `.def'
/tmp/main-7f4d85.s:8: Error: unknown pseudo-op: `.scl'
/tmp/main-7f4d85.s:9: Error: Missing symbol name in directive
/tmp/main-7f4d85.s:9: Error: unrecognized symbol type "32"
/tmp/main-7f4d85.s:10: Error: unknown pseudo-op: `.endef'
/tmp/main-7f4d85.s:30: Error: unknown pseudo-op: `.def'
/tmp/main-7f4d85.s:31: Error: unknown pseudo-op: `.scl'
/tmp/main-7f4d85.s:32: Error: Missing symbol name in directive
/tmp/main-7f4d85.s:32: Error: unrecognized symbol type "32"
/tmp/main-7f4d85.s:33: Error: unknown pseudo-op: `.endef'
/tmp/main-7f4d85.s:68: Fatal error: bad .section directive: want a,w,x,M,S,G,T in string
clang: error: assembler (via gcc) command failed with exit code 1 (use -v to see invocation)

Adding -wc-use-mingw-linker gives the same result:

$ w32-clang -c main.c -o main.obj -wc-use-mingw-linker
/tmp/main-7454e1.s: Assembler messages:
/tmp/main-7454e1.s:1: Error: unknown pseudo-op: `.def'
/tmp/main-7454e1.s:2: Error: unknown pseudo-op: `.scl'
/tmp/main-7454e1.s:3: Error: Missing symbol name in directive
/tmp/main-7454e1.s:4: Error: unknown pseudo-op: `.endef'
/tmp/main-7454e1.s:5: Error: expected symbol name
/tmp/main-7454e1.s:6: Error: junk at end of line, first unrecognized character is `@'
/tmp/main-7454e1.s:7: Error: unknown pseudo-op: `.def'
/tmp/main-7454e1.s:8: Error: unknown pseudo-op: `.scl'
/tmp/main-7454e1.s:9: Error: Missing symbol name in directive
/tmp/main-7454e1.s:9: Error: unrecognized symbol type "32"
/tmp/main-7454e1.s:10: Error: unknown pseudo-op: `.endef'
/tmp/main-7454e1.s:30: Error: unknown pseudo-op: `.def'
/tmp/main-7454e1.s:31: Error: unknown pseudo-op: `.scl'
/tmp/main-7454e1.s:32: Error: Missing symbol name in directive
/tmp/main-7454e1.s:32: Error: unrecognized symbol type "32"
/tmp/main-7454e1.s:33: Error: unknown pseudo-op: `.endef'
/tmp/main-7454e1.s:68: Fatal error: bad .section directive: want a,w,x,M,S,G,T in string
clang: error: assembler (via gcc) command failed with exit code 1 (use -v to see invocation)

Any ideas?

exceptions disabled even on clang 4.0.0

wclang: verbose: command in: x86_64-w64-mingw32-clang++ -wc-verbose -fexceptions -O3 -std=c++14 -shared -I./sdk/public/steam -o steam_interceptor.dll steam_interceptor.def steam_interceptor.cpp -Wl,--exclude-all-symbols -L. -static -lsteam_api64_original
wclang: verbose: command out: /usr/lib64/ccache/clang++ -D__CRT__NO_INLINE -L/usr/lib/gcc/x86_64-w64-mingw32/7.1.0 -target x86_64-w64-mingw32 -nostdinc -nostdinc++ -isystem /usr/x86_64-w64-mingw32/sys-root/mingw/include/c++/ -isystem /usr/x86_64-w64-mingw32/sys-root/mingw/include/c++//x86_64-w64-mingw32 -isystem /usr/x86_64-w64-mingw32/sys-root/mingw/include -fexceptions -O3 -std=c++14 -shared -I./sdk/public/steam -o steam_interceptor.dll steam_interceptor.def steam_interceptor.cpp -Wl,--exclude-all-symbols -L. -static -lsteam_api64_original

version:

[pisto@pisto steam_interceptor]$ x86_64-w64-mingw32-clang++ --version
wclang: warning: cannot find clang intrinsics directory
clang version 4.0.0 (tags/RELEASE_400/final)
Target: x86_64-w64-windows-gnu
Thread model: posix
InstalledDir: /usr/bin

Overriding with the env var appears to work (now tackling another issue so I can't tell if it actually finishes compiling).

error: __float128 is not supported on this target

When I try to compile this program:

#include <cmath>
#include <iostream>

int main()
{
    std::cout << std::acos(-1.0) << std::endl;
    return 0;
}

clang gives the following error:

In file included from pi.cpp:1:
In file included from /usr/x86_64-w64-mingw32/include/c++/7.1.1/cmath:47:
/usr/x86_64-w64-mingw32/include/c++/7.1.1/bits/std_abs.h:102:7: error: __float128 is not supported on this target
  abs(__float128 __x)
      ^
/usr/x86_64-w64-mingw32/include/c++/7.1.1/bits/std_abs.h:101:3: error: __float128 is not supported on this target
  __float128
  ^
2 errors generated.

Can't detect MinGW-w64 of MXE project

Hi! I'm using MXE, which is a MinGW-w64 compiler bundled with tons of makefiles for various libraries, but these guys name their executables differently, for example here's the path to mingw g++ executable:

/opt/mxe/usr/bin/x86_64-w64-mingw32.static-g++

Basically all their executables in bin folder start with x86_64-w64-mingw32.static- prefix.

I tried to export compiler folders to PATH, but it keep showing this error:

checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
mingw-w64 is not installed or not in PATH variable.

Any idea how to detect it? Thanks!

Cannot find x86_64-w64-mingw32 C++ headers

Hello.
How better to solve this problem?
/opt/wc390/bin/x86_64-w64-mingw32-clang++ -wc-help
cannot find x86_64-w64-mingw32 C++ headers
make sure x86_64-w64-mingw32 C++ headers are installed on your system
svost@linux-63qq:~/src/AssemblyLoader>
svost@linux-63qq:/usr/x86_64-w64-mingw32/sys-root/mingw> pwd
/usr/x86_64-w64-mingw32/sys-root/mingw
svost@linux-63qq:/usr/x86_64-w64-mingw32/sys-root/mingw> ls -l
итого 0
drwxr-xr-x 1 root root 202 ноя 7 08:43 bin
drwxr-xr-x 1 root root 25978 ноя 7 08:43 include
drwxr-xr-x 1 root root 30796 ноя 7 08:43 lib
drwxr-xr-x 1 root root 6 ноя 7 08:43 libexec
drwxr-xr-x 1 root root 72 ноя 7 08:43 share
drwxr-xr-x 1 root root 6 ноя 7 08:43 var
also present this folder
/usr/lib64/gcc/x86_64-w64-mingw32/6.2.0/include/c++
svost@linux-63qq:/usr/x86_64-w64-mingw32/sys-root/mingw> /usr/bin/x86_64-w64-mingw32-g++ -v
Using built-in specs.
COLLECT_GCC=/usr/bin/x86_64-w64-mingw32-g++
COLLECT_LTO_WRAPPER=/usr/lib64/gcc/x86_64-w64-mingw32/6.2.0/lto-wrapper
Target: x86_64-w64-mingw32
Configured with: ../configure --prefix=/usr --bindir=/usr/bin --includedir=/usr/include --libdir=/usr/lib64 --libexecdir=/usr/lib64 --mandir=/usr/share/man --infodir=/usr/share/info --datadir=/usr/share --build=x86_64-suse-linux-gnu --host=x86_64-suse-linux-gnu --target=x86_64-w64-mingw32 --with-gnu-as --with-gnu-ld --verbose --without-newlib --disable-multilib --disable-plugin --with-system-zlib --disable-nls --without-included-gettext --disable-win32-registry --enable-version-specific-runtime-libs --with-sysroot=/usr/x86_64-w64-mingw32/sys-root --enable-languages=c,c++,fortran,objc,obj-c++ --without-x --enable-hash-synchronization --enable-fully-dynamic-string --enable-libgomp --enable-linker-build-id --disable-vtable-verify
Thread model: win32
gcc version 6.2.0 (GCC)
svost@linux-63qq:/usr/x86_64-w64-mingw32/sys-root/mingw>
svost@linux-63qq:/etc> cat SuSE-release
openSUSE 42.1 (x86_64)
VERSION = 42.1
CODENAME = Malachite

Errors when host clang defaults to libc++ and compiler-rt

Hi there - I built a Docker container with clang set to default to using libc++ and compiler-rt, so when I run wclang, it too tries to use libc++ and compiler-rt - I'm not 100% positive if these are usable on Windows yet.

Running x86_64-w64-mingw32-clang++ with -rtlib=platform and -stdlib=platform restores the default behavior. I would love to be able to specify a default rtlib and stdlib at compile-time in cmake

C++ exception support for x86

Recent versions of clang (3.9 and later) support C++ exceptions even on x86. (Or at least that's what documentation says...)
I'd love if wclang supported them, too.

LLD?

MinGW's linker is painfully slow. Do you know is it possible to compile and use LLD for windows builds as well?

Clang intrisics can't be found

If I only run
x86_64-w64-mingw32-clang++
With no input, it will warn me that intrisics cannot be found
wclang: warning: cannot find clang intrinsics directory clang-8: error: no input files
If I compile with a input file. It will compile fine if there are no intrinsics in the program. But I will need said intrisics, both to call directly and to use headers like windows.h

Looking in /usr/x86_64-w64-mingw32/include/
intrin.h is available, but not x86intrin.h I don't know if that's relevant.

OS is Arch Linux

Support POSIX threading model for MINGW

The use of godot crosscompiled on Linux requires POSIX threading model.

They suggest:

To use posix mode for mingw by default:

$ sudo update-alternatives --config x86_64-w64-mingw32-gcc
<choose x86_64-w64-mingw32-gcc-posix from the list>
$ sudo update-alternatives --config x86_64-w64-mingw32-g++
<choose x86_64-w64-mingw32-g++-posix from the list>

(godotengine/godot#9258)

I'm not sure how to do this for wclang.

Unable to build SEH

I have built wclang on Ubuntu 16.04 with LLVM 11, which is from http://apt.llvm.org

But it can't build SEH sample by:

i686-w64-mingw32-clang -g -o seh.exe seh.c
seh.c:29:5: error: use of undeclared identifier '__try'
    __try
    ^
1 error generated.

How to solve it?

Cannot compile with `-static` when using exceptions

When trying to compile this program:

#include <exception>
#include <iostream>

class V { virtual void foo(){} };

class A: virtual V {};

class B: public A {};

int main()
{
    B b;
    A& a = b;
    try
    {
        B& new_b = dynamic_cast<B&>(a);
    }
    catch(std::exception& e)
    {
        std::cerr << e.what() << std::endl;
    }
    return 0;
}

with -static I get the following error:

$ x86_64-w64-mingw32-clang++ -o program.exe -pthread -static program.cpp 
/tmp/program-1176a8.o:(.text+0xa2): undefined reference to `__imp___dynamic_cast'
/tmp/program-1176a8.o:(.text+0xb7): undefined reference to `__imp___cxa_bad_cast'
/tmp/program-1176a8.o:(.text+0xf1): undefined reference to `__imp___cxa_begin_catch'
/tmp/program-1176a8.o:(.text+0x146): undefined reference to `__imp___cxa_end_catch'
/tmp/program-1176a8.o:(.text+0x161): undefined reference to `__imp___cxa_end_catch'
/tmp/program-1176a8.o:(.text[__clang_call_terminate]+0x7): undefined reference to `__imp___cxa_begin_catch'
clang-6.0: error: linker command failed with exit code 1 (use -v to see invocation)

This is the complete error log with -v

cannot build with exceptions

Hi again,
Why are exceptions disabled ?
Would it require to link against a cross-compiled version of llvm custom stdlib "libc++" ?
xan.

[SOLVED] CMake expects *.lib instead of *.a libraries

I'm trying to compile dll and link libdbghelp.a to it (with MXE, it's located at /opt/mxe/usr/i686-w64-mingw32.shared/lib/libdbghelp.a):

cmake_minimum_required(VERSION 2.8)
project(test)
add_library(test SHARED main.c)
target_link_libraries(test dbghelp)

mxe-conf.cmake toolchain file that I use (just a standard one with mingw compiler replaced to w32-clang):

$ cat /opt/mxe/usr/i686-w64-mingw32.shared/share/cmake/mxe-conf.cmake 
set(CMAKE_SYSTEM_NAME Windows)
set(MSYS 1)
set(BUILD_SHARED_LIBS ON)
set(LIBTYPE SHARED)
set(CMAKE_BUILD_TYPE Release)
set(CMAKE_FIND_ROOT_PATH /opt/mxe/usr/i686-w64-mingw32.shared)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_C_COMPILER w32-clang)
set(CMAKE_CXX_COMPILER w32-clang++)
set(CMAKE_Fortran_COMPILER /opt/mxe/usr/bin/i686-w64-mingw32.shared-gfortran)
set(CMAKE_RC_COMPILER /opt/mxe/usr/bin/i686-w64-mingw32.shared-windres)
set(CMAKE_MODULE_PATH "/opt/mxe/src/cmake" ${CMAKE_MODULE_PATH}) # For mxe FindPackage scripts
set(CMAKE_INSTALL_PREFIX /opt/mxe/usr/i686-w64-mingw32.shared CACHE PATH "Installation Prefix")
set(CMAKE_BUILD_TYPE Release CACHE STRING "Debug|Release|RelWithDebInfo|MinSizeRel")
set(CMAKE_CROSS_COMPILING ON) # Workaround for http://www.cmake.org/Bug/view.php?id=14075
set(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> -O coff <FLAGS> <DEFINES> -o <OBJECT> <SOURCE>") # Workaround for buggy windres rules
set(HDF5_C_COMPILER_EXECUTABLE /opt/mxe/usr/bin/i686-w64-mingw32.shared-h5cc)
set(HDF5_CXX_COMPILER_EXECUTABLE /opt/mxe/usr/bin/i686-w64-mingw32.shared-h5c++)
set(PKG_CONFIG_EXECUTABLE /opt/mxe/usr/bin/i686-w64-mingw32.shared-pkg-config)
set(QT_QMAKE_EXECUTABLE /opt/mxe/usr/i686-w64-mingw32.shared/qt/bin/qmake)
set(Boost_THREADAPI "win32")

And here's the error I get:

$ cmake .. -DCMAKE_TOOLCHAIN_FILE=/opt/mxe/usr/i686-w64-mingw32.shared/share/cmake/mxe-conf.cmake
-- The C compiler identification is Clang 3.5.1
-- The CXX compiler identification is Clang 3.5.1
-- Check for working C compiler: /usr/local/bin/w32-clang
-- Check for working C compiler: /usr/local/bin/w32-clang -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/local/bin/w32-clang++
-- Check for working CXX compiler: /usr/local/bin/w32-clang++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Configuring done
-- Generating done
-- Build files have been written to: /mnt/space/dev/test/build
constantine@linux /mnt/space/dev/test/build $ make
Scanning dependencies of target test
[100%] Building C object CMakeFiles/test.dir/main.c.obj
Linking C shared library test.dll
/opt/mxe/usr/bin/i686-w64-mingw32.shared-ld: cannot find -ldbghelp.lib
collect2: error: ld returned 1 exit status
clang: error: linker (via gcc) command failed with exit code 1 (use -v to see invocation)
make[2]: *** [test.dll] Error 1
make[1]: *** [CMakeFiles/test.dir/all] Error 2
make: *** [all] Error 2

Note this line:

Linking C shared library test.dll
/opt/mxe/usr/bin/i686-w64-mingw32.shared-ld: cannot find -ldbghelp.lib

It tries to link MSVC-style library, where as I have MinGW *.a one. I could've give it a full path to libdbghelp.a, but it's not possible to do for every library that required by other CMake projects out there... Any ideas how to force CMake to think that wclang is a MinGW compatible compiler? :)

Support MSVC

Could we get support for MSVC targets as well?

Unresolved Dependencies

Everytime I try to build something simple I always run into this issue:

root@4bb1c579744e:/usr/src/cmake-hello-world# w64-clang++ HelloWorld.cpp Hello/Speaker.cpp -ohello_world.exe -IHello
/usr/src/mxe/usr/bin/x86_64-w64-mingw32.static-ld: cannot find crt2.o: No such file or directory
/usr/src/mxe/usr/bin/x86_64-w64-mingw32.static-ld: cannot find crtbegin.o: No such file or directory
/usr/src/mxe/usr/bin/x86_64-w64-mingw32.static-ld: cannot find -lstdc++
/usr/src/mxe/usr/bin/x86_64-w64-mingw32.static-ld: cannot find -lgcc_s
/usr/src/mxe/usr/bin/x86_64-w64-mingw32.static-ld: cannot find -lgcc
/usr/src/mxe/usr/bin/x86_64-w64-mingw32.static-ld: cannot find -lgcc_s
/usr/src/mxe/usr/bin/x86_64-w64-mingw32.static-ld: cannot find -lgcc
/usr/src/mxe/usr/bin/x86_64-w64-mingw32.static-ld: cannot find crtend.o: No such file or directory
clang: error: linker command failed with exit code 1 (use -v to see invocation)

When I add -wc-use-mingw-linker however I can compile without issues. I've followed some steps I found in issues here like setting the COMPILER_PATH, but it doesn't fix the problem. I'm using MXE (although it also happens without this), and clang 3.8.

Any help would be greatly appreciated!

Ubuntu version string of clang may not correct match in CMakeLists.txt

Then default clang --version on Ubuntu 14.04.1 string is:
Ubuntu clang version 3.4-1ubuntu3 (tags/RELEASE_34/final) (based on LLVM 3.4)

which the string REGEX_REPLACE match pattern should become: ".*version ([0-9\\.]+).*" instead ".*version ([0-9\\.]+) .*" when detecting the CLANG_VERSION (we dont need a space after the version number)

Clang: warning: argument unused during compilation:

Hello.
Can I ignore these messages or something went wrong?
novacoin@nvcnode:/opt/wclang/bin$ ./w64-clang++ -v
Ubuntu clang version 3.6.0-2ubuntu1 (tags/RELEASE_360/final) (based on LLVM 3.6.0)
Target: x86_64-w64-windows-gnu
Thread model: posix
clang: warning: argument unused during compilation: '-nostdinc'
clang: warning: argument unused during compilation: '-fno-exceptions'
clang: warning: argument unused during compilation: '-isystem /usr/bin/../lib/clang/3.6/include'
clang: warning: argument unused during compilation: '-isystem /usr/x86_64-w64-mingw32/include'
clang: warning: argument unused during compilation: '-isystem /usr/x86_64-w64-mingw32/include/../../../usr/lib/gcc/x86_64-w64-mingw32/4.9-posix/include/c++'
clang: warning: argument unused during compilation: '-isystem /usr/x86_64-w64-mingw32/include/../../../usr/lib/gcc/x86_64-w64-mingw32/4.9-posix/include/c++/x86_64-w64-mingw32'
novacoin@nvcnode:/opt/wclang/bin$

Support for ARM/ARM64 on Windows

Hello devs,

Is wclang compatible with cross compiling to ARM/ARM64 Windows versions, or will it have a support for these architectures soon?

Wrong ABI for class methods that return structs

I described the bug in the GCC tracker (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81943), here I'll describe what applies to wclang.

wclang (x86_64-w64-mingw32-clang++) uses the wrong ABI, while clang-cl uses the correct one. I believe I pinpointed the difference in arguments to the clang driver to the -triplet argument, that in the case of clang-cl is x86_64-pc-windows-msvc18.0.0. If I force that on wclang (-Xclang -triple -Xclang x86_64-pc-windows-msvc18.0.0), I get the right ABI and the test program compiles. However, I am not sure on the interactions with the mingw-built libstdc++ and such. In any case, wclang as it is now wrongly follows mingw.

llvm 3.8 vs exceptions ?

hi
it seems clang 3.8 supports emitting exceptions now!
can the fno-exception flag be removed ?

CMake fails to run

Build log:

~snip~
-- Try C++11 flag = [-std=gnu++0x]
-- Performing Test CXX11_FLAG_DETECTED
-- Performing Test CXX11_FLAG_DETECTED - Success
-- Found clang: /home/jill/build/git/wclang/clang-4.0
CMake Error at CMakeLists.txt:71 (string):
  string sub-command REGEX, mode REPLACE needs at least 6 arguments total to
  command.


-- Found mingw-gcc: /usr/bin/i686-w64-mingw32-gcc-win32
-- Found mingw-gcc: /usr/bin/x86_64-w64-mingw32-gcc-win32
-- Configuring incomplete, errors occurred!
~snip~

Support for clang ASAN

When I trying to compile a hello world using -fsanitize=address, clang is trying to search for a nonexistent files.

x86_64-w64-mingw32-clang  -fsanitize=address  hello-world.c 
hello-world.c:2:5: warning: implicitly declaring library function 'printf' with type 'int (const char *, ...)' [-Wimplicit-function-declaration]
    printf("Hello World");
    ^
hello-world.c:2:5: note: include the header <stdio.h> or explicitly provide a declaration for 'printf'
1 warning generated.
/usr/bin/x86_64-w64-mingw32-ld: cannot find /usr/lib/llvm-10/lib/clang/10.0.0/lib/windows/libclang_rt.asan_dynamic-x86_64.dll.a: No such file or directory
/usr/bin/x86_64-w64-mingw32-ld: cannot find /usr/lib/llvm-10/lib/clang/10.0.0/lib/windows/libclang_rt.asan_dynamic_runtime_thunk-x86_64.a: No such file or directory
/usr/bin/x86_64-w64-mingw32-ld: cannot find /usr/lib/llvm-10/lib/clang/10.0.0/lib/windows/libclang_rt.asan_dynamic_runtime_thunk-x86_64.a: No such file or directory
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I was wondering if I can't get these files from windows installation.

I sucessfully generate /usr/lib/llvm-10/lib/clang/10.0.0/lib/windows/libclang_rt.asan_dynamic-x86_64.dll.a from the original ./lib/clang/10.0.0/lib/windows/clang_rt.asan_dynamic-x86_64.dll for llvm10 windows installation using gendef and dlltool, but I don't know how to convert the original ./lib/clang/10.0.0/lib/windows/clang_rt.asan_dynamic_runtime_thunk-x86_64.lib to /usr/lib/llvm-10/lib/clang/10.0.0/lib/windows/libclang_rt.asan_dynamic_runtime_thunk-x86_64.a

Are there some way to solve this problem?

Does wclang work with CMake?

README mentions:

"Wclang detects the target and headers automatically and adds them to the clang invocation command."

I'm new to CMake but it does some fiddling of its own, with compiler and linker flags, from what I can see. So far I cannot get CMake to generate a makefile that actually works - there are several discrepancies between running wclang as suggested in the README - which works for me just fine - and using CMake to invoke wclang.

What is _prefix_ in README supposed to be?

I'm sorry if this is a silly question but as I work with wclang I am still trying to figure out whether I was meant to substitute something in for _ prefix _ (without spaces) during the build process, and if so, what?

If it wasn't meant to be the literal "_ prefix _", then perhaps update the README to tell users what it is a placeholder for.

Docs for MXE integration

It seems wclang is MXE-aware at least to some degree.

Some docs on how to use it with MXE would be appreciated (including if MXE is not installed globally).

Specifically:

  • can it be made MXE's default cross compiler (per target)?
  • can it be used to build MXE "internal" packages?
  • etc and stuff I didn't think of?

C++ ABI

I don't think this enables Clang's recent windows ABI compatibility work, since I still see gcc-style name mangling looking at the outputted file.

If this stems from a different between the mingw and win32 targets, how feasible would it be to make this tool also support using MSVC++ headers / libs?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.