From 647e107f0019d2b3f4d3ecb232239ba007936bb5 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 4 Jul 2025 10:05:25 -0500 Subject: [PATCH] adjustments for darwin/clang build --- example/ex1/ex1.cpp | 30 +++++++++++++++++++++++++----- example/ex2_jit/ex2_jit.cpp | 13 +++++++++++-- 2 files changed, 36 insertions(+), 7 deletions(-) diff --git a/example/ex1/ex1.cpp b/example/ex1/ex1.cpp index 22e1b0b7..638e1bda 100644 --- a/example/ex1/ex1.cpp +++ b/example/ex1/ex1.cpp @@ -29,8 +29,28 @@ #include "llvm/Transforms/Scalar/GVN.h" #include "llvm/Transforms/Scalar/Reassociate.h" #include "llvm/Transforms/Scalar/SimplifyCFG.h" +#include -//double foo(double x) { return x; } +namespace { + // need wrappers to fix type signature for osx/clang15. Perhaps sqrt() is a macro or template (?) + double + xo_sqrt(double x) + { + return ::sqrt(x); + } + + double + xo_sin(double x) + { + return ::sin(x); + } + + double + xo_cos(double x) + { + return ::cos(x); + } +} int main() { @@ -82,7 +102,7 @@ main() { } { - auto expr = make_primitive("sqrt", &sqrt, + auto expr = make_primitive("sqrt", &xo_sqrt, false /*!explicit_symbol_def*/, llvmintrinsic::fp_sqrt); @@ -105,7 +125,7 @@ main() { { /* (sqrt 2) */ - auto fn = make_primitive("sqrt", &sqrt, + auto fn = make_primitive("sqrt", &xo_sqrt, false /*!explicit_symbol_def*/, llvmintrinsic::fp_sqrt); auto arg = make_constant(2.0); @@ -132,11 +152,11 @@ main() { /* (lambda (x) (sin (cos x))) */ auto sin = make_primitive("sin", - ::sin, + &xo_sin, false /*!explicit_symbol_def*/, llvmintrinsic::fp_sin); auto cos = make_primitive("cos", - ::cos, + &xo_cos, false /*!explicit_symbol_def*/, llvmintrinsic::fp_cos); diff --git a/example/ex2_jit/ex2_jit.cpp b/example/ex2_jit/ex2_jit.cpp index 3131f823..b21d5e41 100644 --- a/example/ex2_jit/ex2_jit.cpp +++ b/example/ex2_jit/ex2_jit.cpp @@ -33,6 +33,15 @@ //double foo(double x) { return x; } +namespace { + // need wrappers to pin type signature for osx/clang15 + double + xo_sqrt(double x) + { + return ::sqrt(x); + } +} + int main() { using xo::scope; @@ -68,7 +77,7 @@ main() { { auto sqrt = make_primitive("sqrt", - ::sqrt, + &xo_sqrt, false /*!explicit_symbol_def*/, llvmintrinsic::fp_sqrt); @@ -115,7 +124,7 @@ main() { #elif CHOICE == 2 #define FUNCTION_SYMBOL "twice" auto root = make_primitive("sqrt", - ::sqrt, + &xo_sqrt, false /*!explicit_symbol_def*/, llvmintrinsic::fp_sqrt);