Problems with Boost 1.55 on Mavericks - c++

I upgraded my system to Mac OS 10.9 and spent the whole weekend to get my software working. Without many success though…
Some of the tools I need require boost, however I used boost 1.38 before, which simply does not compile on Mavericks. So I decide to use homebrew to install boost 1.55. The installation went without any problems, but when I try to compile my toolset, it throws me this error:
Syntax error /usr/local/include/boost/exception/exception.hpp:343:
Error: void type variable can not be declared /usr/local/include/boost/smart_ptr/shared_ptr.hpp:243:
Error: void type variable can not be declared /usr/local/include/boost/smart_ptr/shared_ptr.hpp:245:
Error: Invalid type '>{typedef' in declaration of 'boost::exception_detail::error_info_base type;}' /usr/local/include/boost/smart_ptr/shared_ptr.hpp:78:
Error: class,struct,union or type element_type not defined /usr/local/include/boost/smart_ptr/shared_ptr.hpp:439:
Internal error: global function template arg type /usr/local/include/boost/smart_ptr/shared_ptr.hpp:439:
Error: Invalid type '>{typedef' in declaration of 'void type;}' /usr/local/include/boost/smart_ptr/shared_ptr.hpp:127:
Internal warning: >{typedef void type;} comment can not set /usr/local/include/boost/smart_ptr/shared_ptr.hpp:127:
Error: Invalid type '>{typedef' in declaration of 'void type;}' /usr/local/include/boost/smart_ptr/shared_ptr.hpp:152:
...
...
...
Warning: Error occurred during reading source files
Warning: Error occurred during dictionary source generation
Error: rootcint: error loading headers...
make[2]: *** [icetray/CMakeFiles/icetrayDict.cxx] Error 1
make[1]: *** [icetray/CMakeFiles/icetray.dir/all] Error 2
make: *** [all] Error 2
I'm not sure what's wrong and don't have a clue where to start to debug this. Google did not return anything helpful, so I'm really struggling right now.
The header files where installed correctly in /usr/local/Cellar and are linked to /usr/local/include.
Btw. I started with a completely fresh Mavericks install (+ Xcode for the devtools) and only used brew to install some additional packages.
This is the quoted code in exception.hpp:
340: struct large_size { char c[256]; };
341: large_size dispatch_boost_exception( exception const * );
343: struct small_size { };
344: small_size dispatch_boost_exception( void const * );
And the corresponding code from the first Error, in smpart_ptr:
239: #if !defined( BOOST_NO_SFINAE ) && !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) && !defined( BOOST_NO_AUTO_PTR )
241: // rvalue auto_ptr support based on a technique by Dave Abrahams
243: template< class T, class R > struct sp_enable_if_auto_ptr
244: {
245: };
247: template< class T, class R > struct sp_enable_if_auto_ptr< std::auto_ptr< T >, R >
248: {
249: typedef R type;
250: };
252: #endif
Compiler flags:
C_FLAGS = -Wall -Wno-mismatched-tags -Wno-char-subscripts -Wno-unused
-Wunneeded-internal-declaration -Wno-parantheses-equality -g -fPIC -I/Users/tamasgal/Xapps/seatray/searecsim/trunk/src/cmake/tool-patches/common
-I/Users/tamasgal/Xapps/seatray/searecsim/trunk/src/icetray/public -I/Users/tamasgal/Xapps/seatray/searecsim/trunk/src/icetray/private -I/usr/local/Cellar/boost/1.55.0/include/boost -I/System/Library/Frameworks/Python.framework/Headers -I/Users/tamasgal/Xapps/i3/seaports/include/log4cplus-1.0.2 -I/Users/tamasgal/Xapps/i3/seaports/root-v5.34.12/include/root -fPIC -fno-strict-aliasing -include /Users/tamasgal/Xapps/seatray/searecsim/trunk/build_debug/CMakeFiles/I3.h
C_DEFINES = -DI3_USE_CINT -DI3_USE_ROOT -DPROJECT=icetray
-D_REEENTRANT
CXX_FLAGS = -Wall -Wno-non-virtual-dtor -Wno-mismatched-tags
-Wno-char-subscripts -Wno-unused -Wunneeded-internal-declaration -Wno-parantheses-equality -g -fPIC -I/Users/tamasgal/Xapps/seatray/searecsim/trunk/src/cmake/tool-patches/common
-I/Users/tamasgal/Xapps/seatray/searecsim/trunk/src/icetray/public -I/Users/tamasgal/Xapps/seatray/searecsim/trunk/src/icetray/private -I/usr/local/Cellar/boost/1.55.0/include/boost -I/System/Library/Frameworks/Python.framework/Headers -I/Users/tamasgal/Xapps/i3/seaports/include/log4cplus-1.0.2 -I/Users/tamasgal/Xapps/i3/seaports/root-v5.34.12/include/root -fPIC -fno-strict-aliasing -include /Users/tamasgal/Xapps/seatray/searecsim/trunk/build_debug/CMakeFiles/I3.h
CXX_DEFINES = -DI3_USE_CINT -DI3_USE_ROOT -DPROJECT=icetray
-D_REEENTRANT
rootcint build command:
cd /Users/tamasgal/Xapps/seatray/searecsim/trunk/build_debug/icetray && \
../env-shell.sh rootcint -f \
/Users/tamasgal/Xapps/seatray/searecsim/trunk/build_debug/icetray/CMakeFiles/icetrayDict.cxx -c -DI3_USE_ROOT -DI3_USE_CINT \
-I/Users/tamasgal/Xapps/seatray/searecsim/trunk/src/cmake/tool-patches/common \
-I/Users/tamasgal/Xapps/seatray/searecsim/trunk/src/icetray/public \
-I/Users/tamasgal/Xapps/seatray/searecsim/trunk/src/icetray/private \
-I/usr/local/Cellar/boost/1.55.0/include/boost \
-I/System/Library/Frameworks/Python.framework/Headers \
-I/Users/tamasgal/Xapps/i3/seaports/include/log4cplus-1.0.2 \
-I/Users/tamasgal/Xapps/i3/seaports/root-v5.34.12/include/root \
-I/Users/tamasgal/Xapps/seatray/searecsim/trunk/src/icetray/public \
-p /Users/tamasgal/Xapps/seatray/searecsim/trunk/build_debug/CMakeFiles/I3.h \
/Users/tamasgal/Xapps/seatray/searecsim/trunk/src/icetray/public/icetray/I3FrameObject.h \
/Users/tamasgal/Xapps/seatray/searecsim/trunk/src/icetray/LinkDef.h
Relevant code part from I3.h:
#define BOOST_NO_WREGEX
#ifdef I3_OPTIMIZE
#define BOOST_DISABLE_ASSERTS
#endif
#include <boost/version.hpp>
#include <boost/shared_ptr.hpp>
using boost::shared_ptr;
using boost::dynamic_pointer_cast;
// workaround for braindead rootcint. doesn't recognize the using
// boost::shared_ptr. I can just see this popping up to cause us
// unspeakable aggravation in the future...
#ifdef __CINT__
template <typename T>
struct shared_ptr : boost::shared_ptr<T> { };

Related

LLVM build using cmake fails during tsan_libdispatch_mac.cc; "Error: conflicting types for ..."

I have at least successfully configured the build for the llvm compiler according to the directions here.
When I go to build using cmake --build . -v I get the following error output:
$ cmake --build . -v
...
[ 63%] Building CXX object projects/compiler-rt/lib/tsan/CMakeFiles/clang_rt.tsan_osx_dynamic.dir/rtl/tsan_libdispatch_mac.cc.o
cd /Users/anthonymcknight/Documents/cubing/bfs/lab4/cilk/llvm/build/projects/compiler-rt/lib/tsan && /usr/bin/clang++ --sysroot=/ -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Dclang_rt_tsan_osx_dynamic_EXPORTS -I/Users/anthonymcknight/Documents/cubing/bfs/lab4/cilk/llvm/build/projects/compiler-rt/lib/tsan -I/Users/anthonymcknight/Documents/cubing/bfs/lab4/cilk/llvm/projects/compiler-rt/lib/tsan -I/Users/anthonymcknight/Documents/cubing/bfs/lab4/cilk/llvm/build/include -I/Users/anthonymcknight/Documents/cubing/bfs/lab4/cilk/llvm/include -I/Users/anthonymcknight/Documents/cubing/bfs/lab4/cilk/llvm/projects/compiler-rt/lib/tsan/.. -isystem / -fPIC -fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wcovered-switch-default -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -std=c++11 -Wall -std=c++11 -O3 -DNDEBUG -arch x86_64 -arch x86_64h -fPIC -stdlib=libc++ -mmacosx-version-min=10.9 -fPIC -fno-builtin -fno-exceptions -fomit-frame-pointer -funwind-tables -fno-stack-protector -fno-sanitize=safe-stack -fvisibility=hidden -fvisibility-inlines-hidden -fno-function-sections -fno-lto -O3 -gline-tables-only -Wno-gnu -Wno-variadic-macros -Wno-c99-extensions -Wno-non-virtual-dtor -fPIE -fno-rtti -msse3 -Wframe-larger-than=512 -Wglobal-constructors -o CMakeFiles/clang_rt.tsan_osx_dynamic.dir/rtl/tsan_libdispatch_mac.cc.o -c /Users/anthonymcknight/Documents/cubing/bfs/lab4/cilk/llvm/projects/compiler-rt/lib/tsan/rtl/tsan_libdispatch_mac.cc
/Users/anthonymcknight/Documents/cubing/bfs/lab4/cilk/llvm/projects/compiler-rt/lib/tsan/rtl/tsan_libdispatch_mac.cc:144:22: error:
conflicting types for 'dispatch_sync'
DISPATCH_INTERCEPT_B(dispatch_sync)
^
/usr/include/dispatch/queue.h:292:1: note: previous declaration is here
dispatch_sync(dispatch_queue_t queue, DISPATCH_NOESCAPE dispatch_block_t block);
^
/Users/anthonymcknight/Documents/cubing/bfs/lab4/cilk/llvm/projects/compiler-rt/lib/tsan/rtl/tsan_libdispatch_mac.cc:145:22: error:
conflicting types for 'dispatch_barrier_sync'
DISPATCH_INTERCEPT_B(dispatch_barrier_sync)
^
/usr/include/dispatch/queue.h:1278:1: note: previous declaration is here
dispatch_barrier_sync(dispatch_queue_t queue,
^
/Users/anthonymcknight/Documents/cubing/bfs/lab4/cilk/llvm/projects/compiler-rt/lib/tsan/rtl/tsan_libdispatch_mac.cc:162:24: error:
conflicting types for 'dispatch_once'
TSAN_INTERCEPTOR(void, dispatch_once, dispatch_once_t *predicate,
^
/usr/include/dispatch/once.h:73:1: note: previous declaration is here
dispatch_once(dispatch_once_t *predicate,
^
3 errors generated.
make[2]: *** [projects/compiler-rt/lib/tsan/CMakeFiles/clang_rt.tsan_osx_dynamic.dir/rtl/tsan_libdispatch_mac.cc.o] Error 1
make[1]: *** [projects/compiler-rt/lib/tsan/CMakeFiles/clang_rt.tsan_osx_dynamic.dir/all] Error 2
make: *** [all] Error 2
I was previously able to workaround buggy compiler flags set by cmake by simply copying and pasting the verbose output and correcting it in the command line, but I'm not sure what to edit here to get things to work.
I've tried changing -isysroot, copying and pasting header files into llvm/include from /usr/include or the MacOSX10.14.sdk file, and the persistent issue is the error: conflicting types ...
I've even tried doing small modifications to tsan_libdispatch_mac.cc but none of them worked (e.g., changing #include <dispatch/dispatch.h> to #include <dispatch.h>, changing "user_alloc" to "user_alloc_internal"...).
Any suggestions are welcome.
Anthony
Basically I had to replace my original tsan_libdispatch_mac.cc with the one form here. I have yet to complete the full installation, much less test performance, but my build is proceeding past this point now.
I tried to compile it for llvm 3.9.1 but the tsan_libdispatch_mac.cc is different. Here's a diff that works:
diff --git a/lib/tsan/rtl/tsan_libdispatch_mac.cc b/lib/tsan/rtl/tsan_libdispatch_mac.cc
index 529cedba4..86982e361 100644
--- a/lib/tsan/rtl/tsan_libdispatch_mac.cc
+++ b/lib/tsan/rtl/tsan_libdispatch_mac.cc
## -144,7 +144,7 ## static void invoke_and_release_block(void *param) {
}
#define DISPATCH_INTERCEPT_SYNC_B(name, barrier) \
- TSAN_INTERCEPTOR(void, name, dispatch_queue_t q, dispatch_block_t block) { \
+ TSAN_INTERCEPTOR(void, name, dispatch_queue_t q, DISPATCH_NOESCAPE dispatch_block_t block) { \
SCOPED_TSAN_INTERCEPTOR(name, q, block); \
SCOPED_TSAN_INTERCEPTOR_USER_CALLBACK_START(); \
dispatch_block_t heap_block = Block_copy(block); \
## -234,7 +234,7 ## TSAN_INTERCEPTOR(void, dispatch_after_f, dispatch_time_t when,
// need to undefine the macro.
#undef dispatch_once
TSAN_INTERCEPTOR(void, dispatch_once, dispatch_once_t *predicate,
- dispatch_block_t block) {
+ DISPATCH_NOESCAPE dispatch_block_t block) {
SCOPED_INTERCEPTOR_RAW(dispatch_once, predicate, block);
atomic_uint32_t *a = reinterpret_cast<atomic_uint32_t *>(predicate);
u32 v = atomic_load(a, memory_order_acquire);
## -444,7 +444,7 ## TSAN_INTERCEPTOR(void, dispatch_source_set_registration_handler_f,
}
TSAN_INTERCEPTOR(void, dispatch_apply, size_t iterations,
- dispatch_queue_t queue, void (^block)(size_t)) {
+ dispatch_queue_t queue, DISPATCH_NOESCAPE void (^block)(size_t)) {
SCOPED_TSAN_INTERCEPTOR(dispatch_apply, iterations, queue, block);
void *parent_to_child_sync = nullptr;

No Emscripten, How to Compile C++ With Standard Library to WebAssembly

I am having trouble building standalone webassembly with the full control I want over memory and layout. I don't want to use emscripten because, as the following post says, it doesn't give me all of the compile-time options I want (e.g. stack size control, being able to choose to import memory in standalone mode, etc.) I've been folowing pages such as: How to generate standalone webassembly with emscripten
Also, emscripten is overkill.
What I've done so far:
I have a fully working llvm 9 toolchain downloaded via homebrew (I am on macos 10.14.)
I was following a mix of https://aransentin.github.io/cwasm/ and https://depth-first.com/articles/2019/10/16/compiling-c-to-webassembly-and-running-it-without-emscripten/
I used wasi to get the C standard library. Using linker flags like -Wl,-z,stack-size=$[1024 * 1024] I could control the stack size. Compilation was successful. Great!
However, I need to use C++ standard libraries to support some of my own and other third party libraries.
As far as I can tell, there doesn't seem to be any easy way to get libc++ and libc++abi.
I tried a "hack" in which I downloaded Emscripten and had it build its own libc++ and libc++abi files. Then I tried copying those files and headers into the right spot.
Then I got error messages referring to a missing threading API, which apparently were caused by not compiling with EMSCRIPTEN. So I defined the EMSCRIPTEN macro and that sort of worked. Then I thought that maybe I could remove the wasi dependency and use emscripten's version of libc to be consistent, but then there were conflicting / missing headers too.
In short, I think I got somewhat close to where I needed to be, but things just got terribly messy. I doubt I took the simplest non-emscripten approach.
Has anyone successfully created a build system for standalone webassembly that lets you use the c and c++ standard libraries?
EDIT:
This is the super hacky build script I have now (it's a heavily modified version of something I found online):
DEPS =
OBJ = library.o
STDLIBC_OBJ = $(patsubst %.cpp,%.o,$(wildcard stdlibc/*.cpp))
OUTPUT = library.wasm
DIR := ${CURDIR}
COMPILE_FLAGS = -Wall \
--target=wasm32-unknown-wasi \
-Os \
-D __EMSCRIPTEN__ \
-D _LIBCPP_HAS_NO_THREADS \
-flto \
--sysroot ./ \
-std=c++17 \
-ffunction-sections \
-fdata-sections \
-I./libcxx/ \
-I./libcxx/support/xlocale \
-I./libc/include \
-DPRINTF_DISABLE_SUPPORT_FLOAT=1 \
-DPRINTF_DISABLE_SUPPORT_LONG_LONG=1 \
-DPRINTF_DISABLE_SUPPORT_PTRDIFF_T=1
$(OUTPUT): $(OBJ) $(NANOLIBC_OBJ) Makefile
wasm-ld \
-o $(OUTPUT) \
--no-entry \
--export-all \
--initial-memory=131072 \
--stack-size=$[1024 * 1024] \
-error-limit=0 \
--lto-O3 \
-O3 \
-lc -lc++ -lc++abi \
--gc-sections \
-allow-undefined-file ./stdlibc/wasm.syms \
$(OBJ) \
$(LIBCXX_OBJ) \
$(STDLIBC_OBJ)
%.o: %.cpp $(DEPS) Makefile
clang++ \
-c \
$(COMPILE_FLAGS) \
-fno-exceptions \
-o $# \
$<
library.wat: $(OUTPUT) Makefile
~/build/wabt/wasm2wat -o library.wat $(OUTPUT)
wat: library.wat
clean:
rm -f $(OBJ) $(STDLIBC_OBJ) $(OUTPUT) library.wat
I dropped-in libc, libc++, and libc++abi from emscripten (but honestly this is a terrible installation process.)
I've been incrementally trying to fill in gaps that I guess emscripten would've normally done, but now I'm stuck again:
./libcxx/type_traits:4837:57: error: use of undeclared identifier 'byte'
constexpr typename enable_if<is_integral_v<_Integer>, byte>::type &
^
./libcxx/type_traits:4837:64: error: definition or redeclaration of 'type'
cannot name the global scope
constexpr typename enable_if<is_integral_v<_Integer>, byte>::type &
I am no longer sure if this will even work since the system might accidentally compile something platform-specific in. Really what I'd like is a shim that would just let me use the standard containers mostly.
This has become kind of unmanageable. What might I do next?
EDIT 2: Right so that's missing C++17 type trait content, and when I go to C++14 (I still want C++17) I end up with more missing things.
Definitely stuck.
EDIT 3:
I sort of started over. The libraries are linking, and I'm able to use the standard, but I'm seeing errors like the following if I try to use e.g. an std::chrono's methods (I can instantiate the object):
wasm-ld: error: /var/folders/9k/zvv02vlj007cc0pm73769y500000gn/T/library-4ff1b5.o: undefined symbol: std::__1::chrono::system_clock::now()
I'm currently using the static library abi from emscripten and the static library C++ standard library from my homebrew installation of llvm (I tried the emscripten one but that didn't work either).
I'm not really sure if this is related to name mangling. I'm currently exporting all symbols from webasm so malloc and co. get exported as well.
Here is my build script:
clang++ \
--target=wasm32-unknown-wasi \
--std=c++11 \
-stdlib=libc++ \
-O3 \
-flto \
-fno-exceptions \
-D WASM_BUILD \
-D _LIBCPP_HAS_NO_THREADS \
--sysroot /usr/local/opt/wasi-libc \
-I/usr/local/opt/wasi-libc/include \
-I/usr/local/opt/glm/include \
-I./libcxx/ \
-L./ \
-lc++ \
-lc++abi \
-nostartfiles \
-Wl,-allow-undefined-file wasm.syms \
-Wl,--import-memory \
-Wl,--no-entry \
-Wl,--export-all \
-Wl,--lto-O3 \
-Wl,-lc++, \
-Wl,-lc++abi, \
-Wl,-z,stack-size=$[1024 * 1024] \
-o library.wasm \
library.cpp
My code:
#include "common_header.h"
#include <glm/glm.hpp>
#include <unordered_map>
#include <vector>
#include <string>
#include <chrono>
template <typename T>
struct BLA {
T x;
};
template <typename T>
BLA<T> make_BLA() {
BLA<T> bla;
std::unordered_map<T, T> map;
std::vector<T> bla2;
std::string str = "WEE";
//str = str.substr(0, 2);
return bla;
}
#ifdef __cplusplus
extern "C" {
#endif
char* malloc_copy(char* input)
{
usize len = strlen(input) + 1;
char* result = (char*)malloc(len);
if (result == NULL) {
return NULL;
}
strncpy(result, input, len);
return result;
}
void malloc_free(char* input)
{
free(input);
}
float32 print_num(float val);
float32 my_sin(float32 val)
{
float32 result = sinf(val);
float32 result_times_2 = print_num(result);
print_num(result_times_2);
return result;
}
long fibonacci(unsigned n) {
if (n < 2) return n;
return fibonacci(n-1) + fibonacci(n-2);
}
void set_char(char* input)
{
input[0] = '\'';
uint8 fibonacci_series[] = { 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89 };
for (uint8 number : fibonacci_series) {
input[0] = number;
}
auto WEE = make_BLA<int>();
WEE.x = 18;
glm::vec4 v(100.0f, 200.0f, 300.0f, 1.0f);
glm::vec4 v_out = glm::mat4(1.0f) * v;
input[0] = 5 + static_cast<int>(v_out.x) * input[1];
auto start = std::chrono::system_clock::now();
long out = fibonacci(42);
auto end = std::chrono::system_clock::now();
std::chrono::duration<double> elapsed_seconds = end-start;
std::time_t end_time = std::chrono::system_clock::to_time_t(end);
auto elapsed = elapsed_seconds.count();
}
#ifdef __cplusplus
}
#endif
When I tried exporting dynamically with the "visible" attribute on only the functions that had no C++, the project compiled, but the wasm module failed to load in JavaScript, so I think the problem was still there.
This is as far as I've gotten. Might the issue be related to the fact that I'm using a different compiler from the one used to create the static libraries? (I'm using homebrew clang 9). Hopefully not. I'd be kind of stuck then because I couldn't find another way to get the libraries. Manual llvm compilation seemed to fail.
The excellent wasi-sdk pulls upstream llvm-project (which provides clang++) and wasi-libc as git submodules and compiles them using suitable flags (most notably disabling pthreads which is not yet supported in wasi-libc).
You can then compile your own C++ source using the following minimal set of options:
/path/to/wasi-sdk/build/install/opt/wasi-sdk/bin/clang++ \
-nostartfiles \
-fno-exceptions \
-Wl,--no-entry \
-Wl,--strip-all \
-Wl,--export-dynamic \
-Wl,--import-memory \
-fvisibility=hidden \
--sysroot /path/to/wasi-sdk/build/install/opt/wasi-sdk/share/wasi-sysroot \
-o out.wasm \
source.cpp
If you want to import functions from the runtime, I would suggest adding an additional line:
-Wl,--allow-undefined-file=wasm-import.syms \
You then can put function names separated by newlines into wasm-import.syms so that the linker won't complain about undefined functions.
Note that all this is completely independent of Emscripten.

LLVM build error due to no matching function

I cloned the LLVM git repositories and followed https://llvm.org/docs/GettingStarted.html. After configuration with
cmake $SOURCEDIR -G "Unix Makefiles" \
-DCLANG_DEFAULT_CXX_STDLIB=libc++ \
-DC_INCLUDE_DIRS=:/usr/include \
-DLLVM_ENABLE_WERROR=OFF \
-DCMAKE_BUILD_TYPE=DEBUG \
-DCMAKE_C_COMPILER=$CC \
-DCMAKE_CXX_COMPILER=$CXX \
-DCMAKE_EXE_LINKER_FLAGS="${LDFLAGS}" \
-DCMAKE_CXX_FLAGS_RELEASE="${CXXFLAGS}" \
-DCMAKE_INSTALL_PREFIX=$INSTALLDIR \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
I tried to build LLVM and Clang with
make -j 24
but it failes (I added new lines for improved readability):
/home/myUserName/LLVM/sources/tools/clang/utils/TableGen/ClangAttrEmitter.cpp:
In constructor ‘{anonymous}::EnumArgument::EnumArgument(const llvm::Record&, llvm::StringRef)’:
/home/myUserName/LLVM/sources/tools/clang/utils/TableGen/ClangAttrEmitter.cpp:740:42:
error: no matching function for call to
‘std::vector<std::__cxx11::basic_string<char> >::vector(std::vector<llvm::StringRef>)’
uniques(uniqueEnumsInOrder(enums))
^
Unfortunately I don't understand why there is a problem, since this function should be declared in
tools/clang/utils/TableGen/ClangAttrEmitter.cpp:722.
This is an excerpt of the corresponding code:
// Unique the enums, but maintain the original declaration ordering.
std::vector<std::string>
uniqueEnumsInOrder(const std::vector<std::string> &enums) {
std::vector<std::string> uniques;
SmallDenseSet<StringRef, 8> unique_set;
for (const auto &i : enums) {
if (unique_set.insert(i).second)
uniques.push_back(i);
}
return uniques;
}
class EnumArgument : public Argument {
std::string type;
std::vector<std::string> values, enums, uniques;
public:
EnumArgument(const Record &Arg, StringRef Attr)
: Argument(Arg, Attr), type(Arg.getValueAsString("Type")),
values(Arg.getValueAsListOfStrings("Values")),
enums(Arg.getValueAsListOfStrings("Enums")),
uniques(uniqueEnumsInOrder(enums))
{
// FIXME: Emit a proper error
assert(!uniques.empty());
}
I use gcc 7.2.0 and Ubuntu 16.04.3 LTS.
Update:
In the meantime I had the chance to build LLVM+Clang with gcc 5.4.0 and the build finished successfully. Does this mean that there is a compiler bug oder is it an issue respectively the gcc standard?

C++ Eclipse g++: error: ./Matrix.o: No such file or directory make: *** [MatrixSample] Error 1

I am trying to make a program that can manipulate matrixes and I am getting that error in Eclipse on Ubuntu 14.04. I searched on google and on stack over flow, but I did not find anything that I could understand and I am stuck. May anybody help me out with this please?
The complete error message:
14:29:27 **** Incremental Build of configuration Debug for project MatrixSample ****
make all
Building file: ../Matrix.inl
Invoking: GCC C++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"Matrix.d" -MT"Matrix.d" -o "Matrix.o" "../Matrix.inl"
g++: warning: ../Matrix.inl: linker input file unused because linking not done
Finished building: ../Matrix.inl
Building target: MatrixSample
Invoking: GCC C++ Linker
g++ -o "MatrixSample" ./Main.o ./Matrix.o
g++: error: ./Matrix.o: No such file or directory
make: *** [MatrixSample] Error 1
Here is the code:
/*
* Main.cpp
*/
#include "Matrix.hpp"
int main()
{
Matrix<int> firstMatrix();
return 0;
}
/*
* Matrix.hpp
*
*/
#ifndef MATRIX_H_
#define MATRIX_H_
template <typename T>
class Matrix
{
public:
Matrix();
private:
int nbrRows;
int nbrColumns;
};
#include "Matrix.inl"
#endif /* MATRIX_H_ */
/*
* Matrix.inl
*/
template <typename T>
Matrix<T>::Matrix()
:nbrRows(0), nbrColumns(0){}
I found what the problem was. I added .inl files as C++ Source file instead of adding it to C++ Header file. Now it's working fine.

Compilation error while compiling an existing code base

While building an existing code base on Mac OS using its native build setup I am getting some basic strange error while compilation phase.
Does any of you have any idea, as I have seen it's been discussed earlier as well in this forum without any good reason. I can not see any conflicting files being included.
But still I am unable to compile the code because this error appears.
Source are like the code given below and compilation error appears
$ cat a.h
#include <string>
#include <sstream>
namespace brijesh {
typedef std::string String;
template<class T>
String toString(T value) {
std::ostringstream buffer;
buffer << value;
return buffer.str();
}
$ cat b.h
#include "a.h"
namespace brijesh {
class Platform {
public:
static String getName();
};
}
$ cat b.cpp
#include "b.h"
namespace brijesh {
String Platform::getName()
{
String name = "UNKNOWN";
#ifdef LINUX
name = "linux";
#endif
#ifdef MACOSX
name = "Mac";
#endif
return name;
}
}
flags used for compilation
g++ -c -o test.o -DRELEASE_VERSION -ggdb -arch ppc -mmacosx-version-min=10.4 -pipe -fpermiss ive -nostdinc -nostdinc++ -isystem /Developer/SDKs/MacOSX10.3.9.sdk/usr/include/gcc/darwin/3 .3 -I/Developer/SDKs/MacOSX10.3.9.sdk/usr/include/gcc/darwin/3.3/c++ -I/Developer/SDKs/MacOS X10.3.9.sdk/usr/include/gcc/darwin/3.3/c++/ppc-darwin -isystem /Developer/SDKs/MacOSX10.3.9. sdk/usr/include -F/Developer/SDKs/MacOSX10.3.9.sdk/System/Library/Frameworks -Wreturn-type -D_REENTRANT -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -Wall -Wno-multichar -Wno-unk nown-pragmas -Wno-long-double -fconstant-cfstrings -MP -MMD x.cpp
/Developer/SDKs/MacOSX10.3.9.sdk/usr/include/gcc/darwin/3.3/c++/bits/locale_facets.h: In constructor 'std::collate_byname<_CharT>::collate_byname(const char*, size_t)':
/Developer/SDKs/MacOSX10.3.9.sdk/usr/include/gcc/darwin/3.3/c++/bits/locale_facets.h:1072: error: '_M_c_locale_collate' was not declared in this scope
/Developer/SDKs/MacOSX10.3.9.sdk/usr/include/gcc/darwin/3.3/c++/ppc-darwin/bits/messages_members.h: In constructor 'std::messages_byname<_CharT>::messages_byname(const char*, size_t)':
/Developer/SDKs/MacOSX10.3.9.sdk/usr/include/gcc/darwin/3.3/c++/ppc-darwin/bits/messages_members.h:79: error: '_M_c_locale_messages' was not declared in this scope
/Developer/SDKs/MacOSX10.3.9.sdk/usr/include/gcc/darwin/3.3/c++/limits: At global scope:
/Developer/SDKs/MacOSX10.3.9.sdk/usr/include/gcc/darwin/3.3/c++/limits:897: error: 'float __builtin_huge_valf()' cannot appear in a constant-expression
/Developer/SDKs/MacOSX10.3.9.sdk/usr/include/gcc/darwin/3.3/c++/limits:897: error: a function call cannot appear in a constant-expression
/Developer/SDKs/MacOSX10.3.9.sdk/usr/include/gcc/darwin/3.3/c++/limits:897: error: 'float __builtin_huge_valf()' cannot appear in a constant-expression
/Developer/SDKs/MacOSX10.3.9.sdk/usr/include/gcc/darwin/3.3/c++/limits:897: error: a function call cannot appear in a constant-expression
/Developer/SDKs/MacOSX10.3.9.sdk/usr/include/gcc/darwin/3.3/c++/limits:899: error: 'float __builtin_nanf(const char*)' cannot appear in a constant-expression
/Developer/SDKs/MacOSX10.3.9.sdk/usr/include/gcc/darwin/3.3/c++/limits:899: error: a function call cannot appear in a constant-expression
/Developer/SDKs/MacOSX10.3.9.sdk/usr/include/gcc/darwin/3.3/c++/limits:899: error: 'float __builtin_nanf(const char*)' cannot appear in a constant-expression
/Developer/SDKs/MacOSX10.3.9.sdk/usr/include/gcc/darwin/3.3/c++/limits:899: error: a function call cannot appear in a constant-expression
/Developer/SDKs/MacOSX10.3.9.sdk/usr/include/gcc/darwin/3.3/c++/limits:900: error: field initializer is not constant
/Developer/SDKs/MacOSX10.3.9.sdk/usr/include/gcc/darwin/3.3/c++/limits:915: error: field initializer is not constant
It looks like you're trying to use OS X 10.3 developer tools (Xcode et al) and are trying to target OS X 10.4, which is obviously not going to work. Either change your build command to remove incompatible flags, such as -mmacosx-version-min=10.4, or upgrade to a more current version of OS X + Xcode + SDKs.