LuaFormatter icon indicating copy to clipboard operation
LuaFormatter copied to clipboard

fix: Add stdc++fs to link path to compatible with gcc

Open winest opened this issue 5 years ago • 5 comments

gcc need to specify libstdc++fs to support when specifying CMAKE_CXX_STANDARD=17 Refer to https://gitlab.kitware.com/cmake/cmake/issues/17834

winest avatar Jan 28 '20 12:01 winest

It's not necessary for our use case. In gcc < 9.0 the library was separate from libstdc++, but even then the portion we use here was not implemented properly and was throwing a segfault. We added a try_run() clause to CMakeLists.txt that runs a small program and checks for the correctness of the APIs we use from fs, in other words, we don't support gcc < 9.0.

tammela avatar Jan 28 '20 14:01 tammela

hmm..that's interesting. I thought it works because I use gcc 8.3(latest on official Ubuntu 1804) with this fix to format 10,000+ files correctly. Anyway, thanks for your check and good code.

winest avatar Jan 29 '20 00:01 winest

@winest you could run the test suite. If it passes, please let me know!

tammela avatar Jan 29 '20 10:01 tammela

@tammela It seems fine.

./lua-format-test line 2:0 mismatched input '#!/bin/lua5.3' expecting <EOF> /home/winest/Apps/LuaFormatter/test/testdata/literals/doublequote.config exist 0 dd /home/winest/Apps/LuaFormatter/test/testdata/literals/singlequote.config exist 0 dd /home/winest/Apps/LuaFormatter/test/testdata/expression/function_2.config exist 0 dd /home/winest/Apps/LuaFormatter/test/testdata/issues/issue-36.config exist 1 dd /home/winest/Apps/LuaFormatter/test/testdata/issues/issue-62_1.config exist 0 dd /home/winest/Apps/LuaFormatter/test/testdata/issues/issue-62_2.config exist 0 dd /home/winest/Apps/LuaFormatter/test/testdata/issues/issue-62_3.config exist 0 dd /home/winest/Apps/LuaFormatter/test/testdata/keep_simple_block_one_line/keep_simple_function_one_line_false.config exist 0 dd /home/winest/Apps/LuaFormatter/test/testdata/keep_simple_block_one_line/keep_simple_control_block_one_line_false.config exist 0 dd =============================================================================== All tests passed (121 assertions in 52 test cases)

My environment:

cmake --version cmake version 3.15.3

gcc --version gcc (Ubuntu 8.3.0-6ubuntu1~18.04.1) 8.3.0

g++ --version g++ (Ubuntu 8.3.0-6ubuntu1~18.04.1) 8.3.0

winest avatar Jan 29 '20 16:01 winest

Confirmed that apparently they fixed this issue (segfault on fs lib) in 8.3.

I did a PR that addressed the code issues here and made it work in all platforms.

Thank you!

tammela avatar Feb 02 '20 21:02 tammela