summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Green <green@moxielogic.com>2014-09-18 18:27:15 -0400
committerAnthony Green <green@moxielogic.com>2014-09-18 18:27:15 -0400
commit4cd5e840122e22636b5838943372c4ed74618e35 (patch)
treee8aa2ebf3b4a096ed062ec3b5b5254ee56012a50
parent1cee07be4712411baa5eb8af22698bc8443a6d6e (diff)
parent08853e32fb6b750cda664ee6d3290d340429dd4d (diff)
downloadlibffi-4cd5e840122e22636b5838943372c4ed74618e35.tar.gz
Merge pull request #123 from ehsan/clang-cl
Add support for building with clang-cl
-rw-r--r--README7
-rw-r--r--include/ffi.h.in2
-rwxr-xr-xmsvcc.sh26
3 files changed, 30 insertions, 5 deletions
diff --git a/README b/README
index 7aee5b4..9cba257 100644
--- a/README
+++ b/README
@@ -146,12 +146,17 @@ It's also possible to build libffi on Windows platforms with
Microsoft's Visual C++ compiler. In this case, use the msvcc.sh
wrapper script during configuration like so:
-path/to/configure CC=path/to/msvcc.sh CXX=path/to/msvcc.sh LD=link CPP=\"cl -nologo -EP\"
+path/to/configure CC=path/to/msvcc.sh CXX=path/to/msvcc.sh LD=link CPP="cl -nologo -EP"
For 64-bit Windows builds, use CC="path/to/msvcc.sh -m64" and
CXX="path/to/msvcc.sh -m64". You may also need to specify --build
appropriately.
+It is also possible to build libffi on Windows platforms with the LLVM
+project's clang-cl compiler, like below:
+
+path/to/configure CC="path/to/msvcc.sh -clang-cl" CXX="path/to/msvcc.sh -clang-cl" LD=link CPP="clang-cl -EP"
+
When building with MSVC under a MingW environment, you may need to
remove the line in configure that sets 'fix_srcfile_path' to a 'cygpath'
command. ('cygpath' is not present in MingW, and is not required when
diff --git a/include/ffi.h.in b/include/ffi.h.in
index 70c6179..ebed0aa 100644
--- a/include/ffi.h.in
+++ b/include/ffi.h.in
@@ -68,7 +68,7 @@ extern "C" {
#ifndef LIBFFI_ASM
-#ifdef _MSC_VER
+#if defined(_MSC_VER) && !defined(__clang__)
#define __attribute__(X)
#endif
diff --git a/msvcc.sh b/msvcc.sh
index 9208076..65fbfef 100755
--- a/msvcc.sh
+++ b/msvcc.sh
@@ -44,7 +44,8 @@
args_orig=$@
args="-nologo -W3"
-md=-MD
+static_crt=
+debug_crt=
cl="cl"
ml="ml"
safeseh="-safeseh"
@@ -63,11 +64,15 @@ do
shift 1
;;
-m64)
- cl="cl" # "$MSVC/x86_amd64/cl"
ml="ml64" # "$MSVC/x86_amd64/ml64"
safeseh=
shift 1
;;
+ -clang-cl)
+ cl="clang-cl"
+ safeseh=
+ shift 1
+ ;;
-O0)
args="$args -Od"
shift 1
@@ -110,9 +115,14 @@ do
defines="$defines $1"
shift 1
;;
+ -DUSE_STATIC_RTL)
+ # Link against static CRT.
+ static_crt=1
+ shift 1
+ ;;
-DUSE_DEBUG_RTL)
# Link against debug CRT.
- md=-MDd
+ debug_crt=1
shift 1
;;
-c)
@@ -207,6 +217,16 @@ if [ -n "$opt" ]; then
args="$args -link -OPT:REF -OPT:ICF -INCREMENTAL:NO"
fi
+if [ -n "$static_crt" ]; then
+ md=-MT
+else
+ md=-MD
+fi
+
+if [ -n "$debug_crt" ]; then
+ md="${md}d"
+fi
+
if [ -n "$assembly" ]; then
if [ -z "$outdir" ]; then
outdir="."