Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in compiling C++ programs using libcxx #104

Open
william4code opened this issue Jul 13, 2022 · 1 comment
Open

Error in compiling C++ programs using libcxx #104

william4code opened this issue Jul 13, 2022 · 1 comment

Comments

@william4code
Copy link

william4code commented Jul 13, 2022

I am using symcc to analyze C++ programs with libcxx.
I follow the document c++.txt in docs.
Firstly, I compile and instrument libcxx using sym++ and install the instrumented libcxx to path: /home/user/programs/libcxx_install
Then I use sym++ to compile my target c++ program main.cpp.
But I get the following error.
It seems that some headers files are missed.

By the way, I can compile and install libcxx without symcc. The uninstrumented libcxx works well on my computer.
I can also use standard cxx library by setting SYMCC_REGULAR_LIBCXX=yes.

The errors are as follows.

===================================
In file included from main.cpp:1:
In file included from /home/user/programs/libcxx_install/include/c++/v1/iostream:37:
In file included from /home/user/programs/libcxx_install/include/c++/v1/ios:214:
/home/user/programs/libcxx_install/include/c++/v1/iosfwd:189:14: error: use of undeclared identifier 'mbstate_t'
typedef fpos<mbstate_t> streampos;
^
/home/user/programs/libcxx_install/include/c++/v1/iosfwd:190:14: error: use of undeclared identifier 'mbstate_t'
typedef fpos<mbstate_t> wstreampos;
^
/home/user/programs/libcxx_install/include/c++/v1/iosfwd:195:14: error: use of undeclared identifier 'mbstate_t'
typedef fpos<mbstate_t> u16streampos;
^
/home/user/programs/libcxx_install/include/c++/v1/iosfwd:196:14: error: use of undeclared identifier 'mbstate_t'
typedef fpos<mbstate_t> u32streampos;
^
In file included from main.cpp:1:
In file included from /home/user/programs/libcxx_install/include/c++/v1/iostream:37:
In file included from /home/user/programs/libcxx_install/include/c++/v1/ios:215:
In file included from /home/user/programs/libcxx_install/include/c++/v1/__locale:14:
In file included from /home/user/programs/libcxx_install/include/c++/v1/string:506:
In file included from /home/user/programs/libcxx_install/include/c++/v1/string_view:175:
In file included from /home/user/programs/libcxx_install/include/c++/v1/__string:57:
In file included from /home/user/programs/libcxx_install/include/c++/v1/algorithm:639:
In file included from /home/user/programs/libcxx_install/include/c++/v1/initializer_list:46:
/home/user/programs/libcxx_install/include/c++/v1/cstddef:49:9: error: no member named 'ptrdiff_t' in the global namespace
using ::ptrdiff_t;
~~^
/home/user/programs/libcxx_install/include/c++/v1/cstddef:50:9: error: no member named 'size_t' in the global namespace
using ::size_t;
~~^
/home/user/programs/libcxx_install/include/c++/v1/cstddef:53:9: error: no member named 'max_align_t' in the global namespace
using ::max_align_t;
~~^
In file included from main.cpp:1:
In file included from /home/user/programs/libcxx_install/include/c++/v1/iostream:37:
In file included from /home/user/programs/libcxx_install/include/c++/v1/ios:215:
In file included from /home/user/programs/libcxx_install/include/c++/v1/__locale:14:
In file included from /home/user/programs/libcxx_install/include/c++/v1/string:506:
In file included from /home/user/programs/libcxx_install/include/c++/v1/string_view:175:
In file included from /home/user/programs/libcxx_install/include/c++/v1/__string:57:
In file included from /home/user/programs/libcxx_install/include/c++/v1/algorithm:639:
/home/user/programs/libcxx_install/include/c++/v1/initializer_list:61:5: error: unknown type name 'size_t'
size_t _size;
^
/home/user/programs/libcxx_install/include/c++/v1/initializer_list:65:38: error: unknown type name 'size_t'
initializer_list(const _Ep* __b, size_t __s) _NOEXCEPT
^
/home/user/programs/libcxx_install/include/c++/v1/initializer_list:73:13: error: unknown type name 'size_t'
typedef size_t size_type;
^
/home/user/programs/libcxx_install/include/c++/v1/initializer_list:84:5: error: unknown type name 'size_t'
size_t size() const _NOEXCEPT {return _size;}
^
In file included from main.cpp:1:
In file included from /home/user/programs/libcxx_install/include/c++/v1/iostream:37:
In file included from /home/user/programs/libcxx_install/include/c++/v1/ios:215:
In file included from /home/user/programs/libcxx_install/include/c++/v1/__locale:14:
In file included from /home/user/programs/libcxx_install/include/c++/v1/string:506:
In file included from /home/user/programs/libcxx_install/include/c++/v1/string_view:175:
In file included from /home/user/programs/libcxx_install/include/c++/v1/__string:57:
In file included from /home/user/programs/libcxx_install/include/c++/v1/algorithm:640:
/home/user/programs/libcxx_install/include/c++/v1/type_traits:1553:32: error: use of undeclared identifier 'size_t'; did you mean 'sizeof'?
: public integral_constant<size_t, 0> {};
^
/home/user/programs/libcxx_install/include/c++/v1/type_traits:1553:38: error: expected expression
: public integral_constant<size_t, 0> {};
^
/home/user/programs/libcxx_install/include/c++/v1/type_traits:1555:32: error: use of undeclared identifier 'size_t'; did you mean 'sizeof'?
: public integral_constant<size_t, rank<_Tp>::value + 1> {};
^
/home/user/programs/libcxx_install/include/c++/v1/type_traits:1555:38: error: expected expression
: public integral_constant<size_t, rank<_Tp>::value + 1> {};
^
/home/user/programs/libcxx_install/include/c++/v1/type_traits:1555:51: error: expected class name
: public integral_constant<size_t, rank<_Tp>::value + 1> {};
^
/home/user/programs/libcxx_install/include/c++/v1/type_traits:1556:22: error: unknown type name 'size_t'
template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS rank<_Tp[_Np]>
^
/home/user/programs/libcxx_install/include/c++/v1/type_traits:1557:32: error: use of undeclared identifier 'size_t'; did you mean 'sizeof'?
: public integral_constant<size_t, rank<_Tp>::value + 1> {};
^
/home/user/programs/libcxx_install/include/c++/v1/type_traits:1557:38: error: expected expression
: public integral_constant<size_t, rank<_Tp>::value + 1> {};
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.

Anyone can help me?

@aur3l14no
Copy link

aur3l14no commented Aug 3, 2023

Try adding nostdinc++ in sym++ script.

stdlib_cflags="-isystem ${!libcxx_var}/include/c++/v1 -nostdinc++ -nostdlib++"

Ref:
https://releases.llvm.org/16.0.0/projects/libcxx/docs/UsingLibcxx.html#using-a-custom-built-libc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants