[PATCH] D135072: Fix llvm build on MacOS
Aleksei Semenov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 3 05:12:20 PDT 2022
alsemenov created this revision.
alsemenov added reviewers: yrouban, skatkov, serge-sans-paille, llvm-commits.
Herald added a subscriber: hiraditya.
Herald added a project: All.
alsemenov requested review of this revision.
Herald added a project: LLVM.
On MacOS build fails with error
[1/1512] Building CXX object lib/Transforms/Utils/CMakeFiles/LLVMTransformUtils.dir/CodeLayout.cpp.o
FAILED: lib/Transforms/Utils/CMakeFiles/LLVMTransformUtils.dir/CodeLayout.cpp.o
/Applications/Xcode11.3.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -DGTEST_HAS_RTTI=0 -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/Users/asemenov/w/llvm-project/build/lib/Transforms/Utils -I/Users/asemenov/w/llvm-project/llvm/lib/Transforms/Utils -I/Users/asemenov/w/llvm-project/build/include -I/Users/asemenov/w/llvm-project/llvm/include -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wstring-conversion -fdiagnostics-color -g -isysroot /Applications/Xcode11.3.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -fno-exceptions -fno-rtti -std=c++17 -MD -MT lib/Transforms/Utils/CMakeFiles/LLVMTransformUtils.dir/CodeLayout.cpp.o -MF lib/Transforms/Utils/CMakeFiles/LLVMTransformUtils.dir/CodeLayout.cpp.o.d -o lib/Transforms/Utils/CMakeFiles/LLVMTransformUtils.dir/CodeLayout.cpp.o -c /Users/asemenov/w/llvm-project/llvm/lib/Transforms/Utils/CodeLayout.cpp
/Users/asemenov/w/llvm-project/llvm/lib/Transforms/Utils/CodeLayout.cpp:659:16: error: call to 'abs' is ambiguous
(std::abs(CurGain.score() - BestGain.score()) < EPS &&
^~~~~~~~
/Applications/Xcode11.3.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/stdlib.h:132:6: note: candidate function
int abs(int) __pure2;
^
/Applications/Xcode11.3.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/stdlib.h:111:44: note: candidate function
inline _LIBCPP_INLINE_VISIBILITY long abs( long __x) _NOEXCEPT {return labs(__x);}
^
/Applications/Xcode11.3.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/stdlib.h:113:44: note: candidate function
inline _LIBCPP_INLINE_VISIBILITY long long abs(long long __x) _NOEXCEPT {return llabs(__x);}
^
1 error generated.
[14/1512] Building CXX object lib/Transforms/Utils/CMakeFiles/LLVMTransformUtils.dir/InlineFunction.cpp.o
ninja: build stopped: subcommand failed
llvm/lib/Transforms/Utils/CodeLayout.cpp uses std::abs() with double argument, which is provided by cmath header, which is not explicitly included into CodeLayout.cpp. The implicit include in llvm/include/llvm/Support/MathExtras.h was removed in commit https://github.com/llvm/llvm-project/commit/16544cbe64b81a50800a88296ef37f4873a37b25
Inserting explicit include of cmath into /CodeLayout.cpp in order to fix build on MacOS
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D135072
Files:
llvm/lib/Transforms/Utils/CodeLayout.cpp
Index: llvm/lib/Transforms/Utils/CodeLayout.cpp
===================================================================
--- llvm/lib/Transforms/Utils/CodeLayout.cpp
+++ llvm/lib/Transforms/Utils/CodeLayout.cpp
@@ -42,6 +42,8 @@
#include "llvm/Transforms/Utils/CodeLayout.h"
#include "llvm/Support/CommandLine.h"
+#include <cmath>
+
using namespace llvm;
#define DEBUG_TYPE "code-layout"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D135072.464653.patch
Type: text/x-patch
Size: 391 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221003/3fc27cd0/attachment.bin>
More information about the llvm-commits
mailing list