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

Cannot compile on Archlinux #1303

Closed
vbmithr opened this issue Feb 21, 2023 · 11 comments
Closed

Cannot compile on Archlinux #1303

vbmithr opened this issue Feb 21, 2023 · 11 comments
Assignees
Labels
bug Something isn't working

Comments

@vbmithr
Copy link

vbmithr commented Feb 21, 2023

CMakeOutput.log

Archlinux x86_64, both with GCC and Clang.

I have errors like

/home/vb/code/aur/kuzu/src/kuzu-0.0.2/src/include/catalog/catalog_structs.h:79:31: error: no member named 'remove_if' in namespace 'std'
        properties.erase(std::remove_if(properties.begin(), properties.end(),
                         ~~~~~^
/home/vb/code/aur/kuzu/src/kuzu-0.0.2/src/include/catalog/catalog_structs.h:87:16: error: use of undeclared identifier 'any_of'
        return any_of(properties.begin(), properties.end(),

Seems like C++20 is not enabled or something even though I see -std=gnu++20 in the log. Not sure what to do.

@mewim
Copy link
Member

mewim commented Feb 21, 2023

Hi @vbmithr,

Thanks for reporting this issue. I was able to reproduce this issue on Arch Linux in Docker and created a patch for this (#1304). With this patch merged, I can now build the latest master on Arch with both gcc (GCC) 12.2.1 20230201 and clang version 15.0.7 installed from pacman. Could you please pull the latest master and let us know if the patch works for you?

@mewim mewim self-assigned this Feb 21, 2023
@mewim mewim added the bug Something isn't working label Feb 21, 2023
@vbmithr
Copy link
Author

vbmithr commented Feb 21, 2023

/home/vb/code/aur/kuzu-git/src/kuzu/src/include/common/utils.h:53:43: error: format string is not a string literal (potentially insecure) [-Werror,-Wformat-security]
        int size_s = snprintf(nullptr, 0, format.c_str(), args...) + 1; // Extra space for '\0'
                                          ^~~~~~~~~~~~~~
/home/vb/code/aur/kuzu-git/src/kuzu/src/common/types/dtime_t.cpp:134:48: note: in instantiation of function template specialization 'kuzu::common::StringUtils::string_format<>' requested here
        throw ConversionException(StringUtils::string_format(
                                               ^
/home/vb/code/aur/kuzu-git/src/kuzu/src/include/common/utils.h:53:43: note: treat the string as an argument to avoid this
        int size_s = snprintf(nullptr, 0, format.c_str(), args...) + 1; // Extra space for '\0'
                                          ^
                                          "%s",
/home/vb/code/aur/kuzu-git/src/kuzu/src/include/common/utils.h:59:35: error: format string is not a string literal (potentially insecure) [-Werror,-Wformat-security]
        snprintf(buf.get(), size, format.c_str(), args...);
                                  ^~~~~~~~~~~~~~
/home/vb/code/aur/kuzu-git/src/kuzu/src/include/common/utils.h:59:35: note: treat the string as an argument to avoid this
        snprintf(buf.get(), size, format.c_str(), args...);
                                  ^
                                  "%s",
2 errors generated.

Now I have this. (Clang)

@mewim
Copy link
Member

mewim commented Feb 21, 2023

Could you please let me know your clang version? Also, does gcc work for you?

@vbmithr
Copy link
Author

vbmithr commented Feb 21, 2023

clang version 15.0.7
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

Same as you. I'm going to try GCC. (12.2.1)

@mewim
Copy link
Member

mewim commented Feb 21, 2023

What command did you use to build the project?

@vbmithr
Copy link
Author

vbmithr commented Feb 21, 2023

make release NUM_THREADS=`nproc` GEN=ninja

@vbmithr
Copy link
Author

vbmithr commented Feb 21, 2023

Similar errors with GCC:

In file included from /home/vb/code/aur/kuzu-git/src/kuzu/src/common/types/dtime_t.cpp:6:
/home/vb/code/aur/kuzu-git/src/kuzu/src/include/common/utils.h: In instantiation of 'static std::string kuzu::common::StringUtils::string_format(const std::string&, Args ...) [with Args = {}; std::string = std::__cxx11::basic_string<char>]':
/home/vb/code/aur/kuzu-git/src/kuzu/src/common/types/dtime_t.cpp:134:61:   required from here
/home/vb/code/aur/kuzu-git/src/kuzu/src/include/common/utils.h:53:30: error: format not a string literal and no format arguments [-Werror=format-security]
   53 |         int size_s = snprintf(nullptr, 0, format.c_str(), args...) + 1; // Extra space for '\0'
      |                      ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/vb/code/aur/kuzu-git/src/kuzu/src/include/common/utils.h:59:17: error: format not a string literal and no format arguments [-Werror=format-security]
   59 |         snprintf(buf.get(), size, format.c_str(), args...);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

@mewim
Copy link
Member

mewim commented Feb 21, 2023

I ran the build again with ninja and it seems I can still complete the build. It looks like in you clang and gcc output that you have a flag -Werror which treats the warnings as errors. Since our CMakeLists.txt does not enable this option (https://github.com/kuzudb/kuzu/blob/master/CMakeLists.txt#L46-L54), I would suggest you to check if you have a global override of the compiler flags, such as CXXFLAGS and CFLAGS in your environment variable.

@vbmithr
Copy link
Author

vbmithr commented Feb 21, 2023

Indeed, I use default Arch makepkg.conf flags

CFLAGS="-march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions \
        -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security \
        -fstack-clash-protection -fcf-protection"

Which uses "format-security" option for -Werror. Those flags are used when building Arch packages so they are probably useful. Please consider making your code compile under format-security

@mewim
Copy link
Member

mewim commented Feb 21, 2023

Thanks for the suggestion. We will create an issue for format security. If you do not use the format security option (CFLAGS="" make release NUM_THREADS=$(nproc) GEN=ninja), are you able to complete the build?

@vbmithr
Copy link
Author

vbmithr commented Feb 21, 2023

Yes, it compiles, thanks. Feel free to close the issue, but I consider it open as long as it's not possible to create a Kuzu Archlinux package without a hack.

@mewim mewim closed this as completed Feb 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants