Skip to content

Commit 45a9fb4

Browse files
authored
Merge branch 'main' into warnings-in-parse.y
2 parents e65eeec + 3c0b71a commit 45a9fb4

File tree

236 files changed

+10420
-3269
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

236 files changed

+10420
-3269
lines changed

.github/pull_request_template.md

+22-12
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,43 @@
11
<!--
2-
Thank you so much for your PR! To help us review, fill out the form to the best of your ability. Please make use of the development guide at https://enzo-e.readthedocs.io/en/main/devel/index.html
2+
Thank you so much for your Pull Request! To help us review it, please fill out this template to the best of your ability. Please make use of the development guide at https://enzo-e.readthedocs.io/en/main/devel/index.html
33
4-
(For context, all of this text enclosed by these fancy brackets are comments that won't be rendered by GitHub)
4+
If you're unfamiliar with this process, here are some formatting basics:
5+
* any text enclosed by fancy brackets (<!~~ and ~~>, but you need to replace "~~" with "--"), is considered a comment that won't be rendered by GitHub after you post your pull request
6+
7+
* GitHub will render all other text will be rendered. It respects markdown escape sequences to control formatting (e.g. lines starting with `###` specify a section-heading)
58
-->
69

710

8-
### Pull request summary
11+
<!--Provide a general summary of your changes in the title above, for
12+
example "Fixes crash in gravity solver in super-cycling". Please avoid
13+
non-descriptive titles such as "Addresses issue #42".-->
14+
15+
<!-- If you are able to do so, please do not create the PR out of main, but out of a separate branch. -->
916

10-
Provide a general summary of your changes in the title above, for example "Fixes crash in gravity solver in super-cycling". Please avoid non-descriptive titles such as "Addresses issue #42".
1117

12-
If you are able to do so, please do not create the PR out of main, but out of a separate branch.
18+
### Pull request summary
19+
20+
<!-- Please provide a brief summary of your changes here. -->
1321

1422
### Detailed Description
1523

24+
<!--
1625
Please provide at least 1-2 sentences describing the pull request in detail. Why is this change required? What problem does it solve?
1726
18-
If it fixes an open issue, please link to the issue here. Github will [autolink](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/autolinked-references-and-urls) if prefixed with a hash, e.g. #42.
19-
20-
If your PR depends on another PR, please link to the PR here [github autolinking syntax](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/autolinked-references-and-urls).
27+
If it fixes an open issue, please mention the issue that it addresses here and provide a link to the issue. GitHub will automatically link any number prefixed with a hash, e.g. #42, to the appropiate issue.
2128
22-
<!--
23-
If you expect that this PR is a major change that will require two reviewers, please replace the `[ ]` text on the following line with `[x]`
29+
If your PR depends on another PR, please link to the PR here. For example, you might say "This PR depends upon #84." (again, GitHub automatically makes links any number prefixed with a hash)
2430
-->
2531

26-
- [ ] This is a major change or addition. Will require two reviewers.
32+
33+
<!-- Please replace yes/no/unknown on the following line with one of those three options based on whether you expect that this PR is a major change that will require two reviewers -->
34+
This is a major change or addition (that needs 2 reviewers): yes/no/unknown
2735

2836
### PR Checklist
2937

30-
Note that some of these check boxes may not apply to all pull requests.
38+
<!-- This is a checklist of tasks that a PR needs to complete. To indicate that you have finished the task, replace the `[ ]` text on the following line(s) with `[x]`.
39+
40+
Note that some of these check boxes may not apply to all pull requests.-->
3141

3242
- [ ] New features are documented with narrative docs.
3343
- [ ] Adds a test for any bugs fixed. Adds tests for new features.

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
*~
2+
.DS_Store
23
build
34
build-*
45
charmrun

CMakeLists.txt

+9-25
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ endif()
3636
# Ensure the custom modules to find Charm++ and Grackle are included
3737
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
3838

39+
# confirm that std::filesystem is supported by the compiler and create an
40+
# interface target called StdFilesystem::StdFilesystem that encapsulates
41+
# usage requirements (if there are any)
42+
include("CreateStdFilesystemTarget")
43+
create_StdFilesystem_target()
44+
3945
#----------------------------------------------------------------------------------------
4046
# External libs
4147

@@ -52,7 +58,7 @@ endif()
5258

5359
find_package(Charm REQUIRED)
5460
# Link executables with the charmc wrapper
55-
STRING(REGEX REPLACE "<CMAKE_CXX_COMPILER>" "${CHARM_COMPILER}"
61+
STRING(REGEX REPLACE "<CMAKE_CXX_COMPILER>" "${CHARM_LINKER}"
5662
CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE}")
5763

5864

@@ -64,15 +70,10 @@ option(GRACKLE_USE_STATIC_LIBS "sets Grackle's lib-type if USE_GRACKLE=ON" ON)
6470
if (USE_GRACKLE)
6571
find_package(Grackle)
6672
if (Grackle_FOUND)
67-
# Setting global compile def as performance and simulation Cello libs need the var
68-
# We should discuss the use of a central config.hpp (similar to the existing
69-
# auto_config.def but also centrally included beyond informational output).
73+
# This really only needs to be defined for a relatively small subset of
74+
# files in the Enzo-layer
7075
add_compile_definitions(CONFIG_USE_GRACKLE)
7176

72-
# Also specifically setting the defines used in the *.ci files of Cello and Enzo.
73-
# Alternatively, figure out a way to extract those from the `COMPILE_DEFINITIONS`
74-
# property and directly process in `cmake/charm.cmake`.
75-
set(CHARM_PREPROC_DEFS ${CHARM_PREPROC_DEFS} "-DCONFIG_USE_GRACKLE ")
7677
else()
7778
message(FATAL_ERROR
7879
"Configured to use Grackle but Grackle library not found.\n"
@@ -81,23 +82,6 @@ if (USE_GRACKLE)
8182
endif()
8283
endif()
8384

84-
# TODO: remove the dependency on boost::filesystem (since C++17 now offers
85-
# nearly identical functionality within the standard library). Initially, I
86-
# thought, it could make sense to keep using boost::filesystem in the
87-
# short-term since the clang compiler shipped on macOS didn't support this
88-
# library until version 11.0 of Xcode (requires macOS Mojave from 2018).
89-
# - Apple's clang compiler supports all new language features & the majority of
90-
# new library features by version 10 (requires macOS High Sierra from 2017)
91-
# - For more info: https://en.cppreference.com/w/cpp/compiler_support/17
92-
# - After giving this some thought, this difference in support is probably not
93-
# worth caring about
94-
find_package(Boost REQUIRED COMPONENTS filesystem)
95-
# Fix linking error to
96-
# /opt/apps/gcc/8.3.0/bin/ld: main.cpp:(.text+0x679e): undefined reference to `boost::system::generic_category()'
97-
# /opt/apps/gcc/8.3.0/bin/ld: main.cpp:(.text+0x67aa): undefined reference to `boost::system::system_category()'
98-
# due to deprecated code (`filesystem` depends on `system`).
99-
add_compile_definitions(BOOST_SYSTEM_NO_DEPRECATED)
100-
10185
find_package(PNG REQUIRED)
10286
add_compile_definitions(NO_FREETYPE)
10387

cmake/CreateStdFilesystemTarget.cmake

+208
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
1+
# See LICENSE_ENZO file for license and copyright information
2+
3+
#.rst:
4+
# CreateStdFilesystemTarget
5+
# -------------------------
6+
#
7+
# This module defines the create_StdFilesystem_target function
8+
#
9+
# That function:
10+
# - confirms that the chosen compiler supports the file system library included
11+
# in the standard library starting in C++17
12+
# - defines the StdFilesystem::StdFilesystem library to communicate extra usage
13+
# requirements
14+
#
15+
# In 99% of cases, there shouldn't be any usage requirements. The main
16+
# exception relates to the implementations of the standard libraries that were
17+
# available around the time that the c++17 standard was ratified. For example:
18+
# - libstdc++ (GNU's implementation) required the `-lstdc++fs` flag
19+
# - libc++ (LLVM's implementation) required the `-lc++fs` flag
20+
# This extra argument mirrors the way in which implementations of libc on unix
21+
# systems may require the `-lm` flag when using math functions.
22+
#
23+
# At the time of writing this, much of the extra functionality for enabling
24+
# compatability with these older versions is hypothetical (it hasn't been
25+
# tested).
26+
#
27+
# FUTURE WORK
28+
# It may be worth asking "do we want to support these older versions?" Or do we
29+
# simply want to test if things "just work" out of the box? If things break in
30+
# the latter case, we could just say what's probably going wrong and tell the
31+
# user that they probably need to upgrade. As time progresses, the latter
32+
# option will become more appealing (and delete ~50% of this file's logic)
33+
34+
function(_detect_stdlib_impl output_variable)
35+
# writes the name of the standard library implementation to the variable name
36+
# specifed by output_variable
37+
# -> known options include
38+
# "libstdc++" (The GNU implementation)
39+
# "libc++" (The LLVM implementation)
40+
# "unknown"
41+
# -> Note: the standard library doesn't have to match the compiler (e.g.
42+
# clang on linux often uses libstdc++)
43+
44+
set(test_file
45+
${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/std-fs/stdimpl.cpp)
46+
47+
# this detection stategy, won't work for libstdc++ older than 6.1
48+
# (but that's okay, such versions are older than C++17)
49+
file(WRITE ${test_file}
50+
"
51+
// include headers defining implementation-specific macros (since we include
52+
// <iostream>, this may not be strictly necessary)
53+
#if __has_include(<ciso646>)
54+
// pre c++20, this header is commonly included for std library implementation
55+
// macros: https://en.cppreference.com/w/cpp/header/version
56+
#include <ciso646>
57+
#else
58+
#include <version>
59+
#endif
60+
61+
#include <iostream>
62+
int main(int argc, char* argv[]){
63+
#ifdef __GLIBCXX__
64+
std::cout << \"libstdc++\\n\";
65+
#elif defined(_LIBCPP_VERSION)
66+
std::cout << \"libc++\\n\";
67+
#else
68+
std::cout << \"unknown\\n\";
69+
#endif
70+
return 0;
71+
}")
72+
73+
try_run(exit_code compile_success ${CMAKE_BINARY_DIR} ${test_file}
74+
RUN_OUTPUT_VARIABLE test_output
75+
)
76+
77+
if(compile_success AND (exit_code EQUAL 0)) # successful test
78+
string(STRIP "${test_output}" stripped_implementation_name)
79+
set(${output_variable} "${stripped_implementation_name}" PARENT_SCOPE)
80+
else()
81+
message(FATAL_ERROR "Something unexpected happened")
82+
endif()
83+
endfunction()
84+
85+
86+
function(_StdFilesystem_try_compile link_library output_variable)
87+
# compile & run a test program with std::filesystem
88+
# -> stores a value of 1 or 0 (denoting success) in the output_variable
89+
90+
set(test_file
91+
${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/std-fs/test.cpp)
92+
93+
# the whole point is for this to be extremely simple
94+
file(WRITE ${test_file}
95+
"
96+
#include <filesystem>
97+
#include <iostream>
98+
99+
int main(int argc, char* argv[]){
100+
std::cout << std::filesystem::temp_directory_path();
101+
return 0;
102+
}")
103+
104+
if (link_library STREQUAL "")
105+
try_run(exit_code compile_success ${CMAKE_BINARY_DIR} ${test_file}
106+
RUN_OUTPUT_VARIABLE test_output
107+
)
108+
else()
109+
try_run(exit_code compile_success ${CMAKE_BINARY_DIR} ${test_file}
110+
LINK_LIBRARIES ${link_library}
111+
RUN_OUTPUT_VARIABLE test_output
112+
)
113+
endif()
114+
115+
if(compile_success AND (exit_code EQUAL 0)) # successful test
116+
set(${output_variable} "1" PARENT_SCOPE)
117+
else()
118+
set(${output_variable} "0" PARENT_SCOPE)
119+
endif()
120+
endfunction()
121+
122+
function(_create_StdFilesystem_target_helper link_library)
123+
add_library(StdFilesystem::StdFilesystem INTERFACE IMPORTED)
124+
if(NOT ${link_library} STREQUAL "")
125+
target_link_libraries(StdFilesystem::StdFilesystem
126+
INTERFACE "${link_library}")
127+
endif()
128+
endfunction()
129+
130+
function(create_StdFilesystem_target)
131+
# this does the heavy lifting
132+
if(TARGET StdFilesystem::StdFilesystem)
133+
return()
134+
elseif(DEFINED CACHE{__StdFilesystem_LINKLIBRARY})
135+
_create_StdFilesystem_target_helper("${__StdFilesystem_LINKLIBRARY}")
136+
return()
137+
endif()
138+
139+
set(BASE_MSG "Checking std::filesystem support")
140+
message(STATUS "${BASE_MSG}")
141+
142+
# first, we try without any link-library
143+
set(link_library "")
144+
set(compile_success "0")
145+
_StdFilesystem_try_compile("${link_library}" compile_success)
146+
147+
if (compile_success)
148+
set(SUCCESS_MSG "works out of the box")
149+
else()
150+
# first provide a nice error message for specific compilers
151+
if(CMAKE_CXX_COMPILER_VERSION STREQUAL "AppleClang")
152+
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "11.0.0")
153+
message(FATAL_ERROR
154+
"Version ${CMAKE_CXX_COMPILER_VERSION} of Apple's Clang compiler "
155+
"does NOT support std::filesystem. Please upgrade to version "
156+
"11.0.0 or newer (you probably have to update Xcode). Alternatively "
157+
"install a different c++ compiler on your system")
158+
else()
159+
message(FATAL_ERROR "Unclear why Apple's Clang compiler isn't working")
160+
endif()
161+
endif()
162+
163+
# gracefully handle cases where the user has an older version of a
164+
# standard-library implementation that requires extra compiler args
165+
# - NOTE: the precise implementation does not necessarily correspond to the
166+
# compiler (e.g. GNU's implementation is commonly used with clang++)
167+
_detect_stdlib_impl(stdlib_impl)
168+
169+
if (stdlib_impl STREQUAL "libstdc++")
170+
# this is the GNU implementation of the standard library
171+
set(link_library "stdc++fs")
172+
set(min_req_vers "8.0.0")
173+
set(link_lib_unneeded_vers "9.1")
174+
_StdFilesystem_try_compile("${link_library}" compile_success)
175+
elseif (stdlib_impl STREQUAL "libc++")
176+
# this is the LLVM implementation of the standard library
177+
set(link_library "c++fs")
178+
set(min_req_vers "7")
179+
set(link_lib_unneeded_vers "9")
180+
_StdFilesystem_try_compile("${link_library}" compile_success)
181+
else()
182+
message(FATAL_ERROR
183+
"std::filesystem doesn't work and the implementation of the standard"
184+
"library can't be determined (it's not a recent version of libstdc++ "
185+
"or libc++). It's likely that: the implementation doesn't support "
186+
"std::filesystem OR we may need to pass an extra linker flag to use "
187+
"std::filesystem (as is required by earlier versions of libstdc++ or "
188+
"libc++)")
189+
endif()
190+
191+
if(NOT compile_success)
192+
message(FATAL_ERROR
193+
"std::filesystem doesn't work. You appear to be using the "
194+
"${stdlib_impl} implementation of the standard library. Note that a "
195+
"version of at least ${min_req_vers} is required.")
196+
endif()
197+
set(SUCCESS_MSG
198+
"works with the linker flag -l${link_library} (this is requirement of "
199+
"${stdlib_impl} before version ${link_lib_unneeded_vers}")
200+
endif()
201+
202+
message(STATUS "${BASE_MSG} -- ${SUCCESS_MSG}")
203+
204+
set(__StdFilesystem_LINKLIBRARY "${link_library}" CACHE INTERNAL
205+
"empty-string or library we must link against to use std::filesystem")
206+
_create_StdFilesystem_target_helper("${__StdFilesystem_LINKLIBRARY}")
207+
208+
endfunction()

0 commit comments

Comments
 (0)