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

build: yet another C++20 migration #2341

Closed
wants to merge 12 commits into from
Closed

Conversation

scarf005
Copy link
Member

@scarf005 scarf005 commented Feb 13, 2023

Summary

SUMMARY: Build "Migrate to C++20"

Purpose of change

continuation of #1624 and #2003

Describe the solution

Todos

  • Didn't astyle have issues with the spaceship operator?
  • We can't just change our entire code style, it would prevent most C++ ports from DDA.
  • JSON errors interfere with checks, needs a rebase
  • Fix android build failure
  • Migrate lit.cfg to C++20
  • Isn't macOS 11 still maintained?
  • Docs will need an update regarding minimal compiler versions, minimal macOS version. Docs still mention macOS 10, g++ 4.8 and clang 3.8

@github-actions github-actions bot added src changes related to source code. tests changes related to tests labels Feb 13, 2023
@scarf005 scarf005 closed this Mar 27, 2023
@scarf005 scarf005 reopened this Mar 27, 2023
@scarf005 scarf005 marked this pull request as ready for review March 27, 2023 00:34
@scarf005 scarf005 changed the title Build: yet another C++20 migration [CR] Build: yet another C++20 migration Mar 27, 2023
@scarf005 scarf005 marked this pull request as draft March 27, 2023 00:40
@scarf005
Copy link
Member Author

i hate c++

@scarf005 scarf005 force-pushed the c++20 branch 2 times, most recently from 0c0ee58 to 3956633 Compare March 28, 2023 15:50
@scarf005 scarf005 marked this pull request as ready for review March 28, 2023 15:50
@olanti-p
Copy link
Contributor

olanti-p commented Mar 28, 2023

  1. Didn't astyle have issues with the spaceship operator? We can't just change our entire code style, it would prevent most C++ ports from DDA.
  2. JSON errors interfere with checks, needs a rebase
  3. Unclear what's up with Android build
  4. Does the Windows/cygwin build work? It's not in CI
  5. Do the MXE Windows releases work? They're not in PR checks
  6. Has tidy been migrated? lit.cfg still has the c++17 switch
  7. Isn't macOS 11 still maintained?
  8. Docs will need an update regarding minimal compiler versions, minimal macOS version. Docs still mention macOS 10, g++ 4.8 and clang 3.8

@scarf005
Copy link
Member Author

scarf005 commented Mar 28, 2023

Didn't astyle have issues with the spaceship operator?

yes. I had to add // *NOPAD* to ignore these lines. they're fixed in 3.2 but contributors will have to manually download them atm, because latest version on ubuntu is 3.1

Unclear what's up with Android build

I'm suspecting it's related to gradle, investigating

Isn't macOS 11 still maintained?

could you clarify? should i downgrade the requirement to macOS 11?

Does Windows/cygwin build work? It's not in CI

Do the MXE Windows releases work? They're not in PR checks

should i add build matrix target or ask for help to other windows users? i'm unable to access windows atm

We can't just change our entire code style, it would prevent most C++ ports from DDA.

do you mean the auto returns?

@olanti-p
Copy link
Contributor

olanti-p commented Mar 28, 2023

could you clarify? should i downgrade the requirement to macOS 11?

I was concerned about dropping support for osx 11, which people still may be using, but our download stats show up as single digits for OSX, and there's no way to tell which exact versions people use, so I guess it doesn't matter much...

should i add build matrix target or ask for help to other windows users? i'm unable to access windows atm

Cygwin can be fixed at a later time if needed then, it's rather obscure and usually works as long as the MSYS build works.

MXE build doesn't need Windows to compile: it's a cross-build from Linux, and can be tested on Github by enabling actions in settings of a BN fork and then pushing to upload. It should at least compile, it's our main windows release builds at the moment (the "non-msvc" ones)

- name: Windows Tiles x64
mxe: x86_64
mxe_apt: x86-64
artifact: windows-tiles-x64
os: ubuntu-20.04
ext: zip
content: application/zip
- name: Windows Tiles x32
mxe: i686
mxe_apt: i686
artifact: windows-tiles-x32
os: ubuntu-20.04
ext: zip
content: application/zip

do you mean the auto returns?

I meant as in moving to other formatting tools that support the spaceship operator, like clang-format, in a way that would end up reformatting tons of lines.

@scarf005
Copy link
Member Author

i see. i think we could wait until astyle 3.2 (which supports spaceship operator) , and until then ignore those lines since we won't be using spaceship operator more than 10 times.

as for the android build failure, this looks like due to outdated gradle version.

@scarf005 scarf005 force-pushed the c++20 branch 5 times, most recently from c0c78b1 to 91233b5 Compare March 29, 2023 06:31
@cataclysmbnteam cataclysmbnteam deleted a comment from github-actions bot Mar 29, 2023
@cataclysmbnteam cataclysmbnteam deleted a comment from github-actions bot Mar 29, 2023
@cataclysmbnteam cataclysmbnteam deleted a comment from github-actions bot Mar 29, 2023
@cataclysmbnteam cataclysmbnteam deleted a comment from github-actions bot Mar 29, 2023
src/units_def.h Outdated Show resolved Hide resolved
NUM_SEASONS ) ) % NUM_SEASONS;
const size_t next_season = ( current_season + 1 ) % NUM_SEASONS;
num_seasons ) ) % num_seasons;
const size_t next_season = ( current_season + 1 ) % num_seasons;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it safe to % unsigned?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i guess it's okay, as divider(num_seasons) is 4. i could change them to int.

@scarf005 scarf005 force-pushed the c++20 branch 2 times, most recently from 90f4c29 to f24a9a0 Compare April 24, 2023 11:25
@scarf005
Copy link
Member Author

scarf005 commented Apr 24, 2023

(copied from discord)
so clang-tidy is dying because it fails to parse <=> operator.
looks like it's fixed in clang 13? ...which means we'll have to also update our custom clang-tidy program.
that looks like a lot of work...
https://bugs.llvm.org/show_bug.cgi?id=47511

possible solution:

  • rollback and manually define all these operators again (yuck)
  • try compiling cata-clang-tidy plugin without using homebrew clang12 (will take ages)
  • ignore this happened (constant clang-tidy death)

scarf005 and others added 12 commits April 25, 2023 23:28
also
1) fix incomplete achievement_requirement

2) remove user defined copy constructor: error: definition of implicit copy assignment operator for 'point_with_value' is deprecated because it has a user-declared copy constructor [-Werror,-Wdeprecated-copy]

Co-authored-by: AngelicosPhosphoros <[email protected]>
1. add `concepts_utility.h` for storing useful concepts related headers.
2. uses `Arithmatic` concepts to ensure they're numbers.
3. uses spaceship operator for comparison.
4. uses auto and arrow returns to make templates readable.
5. make fabs and fmod constexpr.

Co-authored-by: Coolthulhu <[email protected]>
it works as a false positive on spaceship operators `<=>`
Co-authored-by: Brett Dong <[email protected]>
scarf005 added a commit to scarf005/Cataclysm-BN that referenced this pull request Apr 25, 2023
fixed by using legacy comparison operators

clang-tidy 12 used by cata-clang-tidy cannot handle spaceship operator

see: cataclysmbnteam#2341 (comment)
@scarf005
Copy link
Member Author

used old operators again, confirmed it compiles in clang++

@scarf005
Copy link
Member Author

oh it's no use trying to remove <=>, c++ stdlib uses them anyway

 + '[' -f build/tools/clang-tidy-plugin/libCataAnalyzerPlugin.so ']'
+ LD_PRELOAD=build/tools/clang-tidy-plugin/libCataAnalyzerPlugin.so
+ clang-tidy -quiet tests/vehicle_test.cpp
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.
Stack dump:
0.	Program arguments: clang-tidy -quiet tests/algo_test.cpp
1.	<eof> parser at end of file
2.	While analyzing stack: 
	#0 Calling std::lexicographical_compare_three_way at line /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/stl_vector.h:2056:14
	#1 Calling std::operator<=> at line /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/predefined_ops.h:45:16
	#2 Calling __gnu_cxx::__ops::_Iter_less_iter::operator() at line /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/stl_algo.h:1809:8
	#3 Calling std::__insertion_sort at line /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/stl_algo.h:1854:2
	#4 Calling std::__final_insertion_sort at line /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/stl_algo.h:1940:4
	#5 Calling std::__sort at line /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/stl_algo.h:4820:7
	#6 Calling std::sort at line 22
	#7 Calling check_cycle_finding at line 35
	#8 Calling C_A_T_C_H_T_E_S_T_1

Copy link
Contributor

@olanti-p olanti-p left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is still stuck on the tidy plugin, we could try porting DDA's migration to LLVM 16
CleverRaven/Cataclysm-DDA#65381
At the very least, this would simplify our tidy workflow since clang-tidy-16 supports plugins "out of the box" (we don't have to compile a hacked version for local testing).

@scarf005 scarf005 marked this pull request as draft August 5, 2023 04:24
@scarf005
Copy link
Member Author

closing as this is stuck on #3028 which also is unlikely to be merged in near future

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
src changes related to source code. tests changes related to tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants