8000 Compiler with path new by hiker · Pull Request #435 · MetOffice/fab · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Compiler with path new #435

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

Open
wants to merge 614 commits into
base: main
Choose a base branch
from
Open

Compiler with path new #435

wants to merge 614 commits into from

Conversation

hiker
Copy link
Collaborator
@hiker hiker commented Jul 9, 2025

This new branch tries to resolve all conflicts that #402 had (i.e. it's a merge of 402 with Matthew's changes).

lukehoffmann and others added 30 commits August 21, 2024 17:56
Bash-style substitution is not currently handled
Previously they were passed into the Linker.link() function
Linker flags for common libraries
@hiker hiker marked this pull request as draft July 9, 2025 15:53
@hiker hiker added enhancement New feature or request Priority Indicate an issue that should be done in the near future. Blocked Blocked by another issue Release Items that are required for the next release labels Jul 9, 2025
@hiker hiker mentioned this pull request Jul 9, 2025
@t00sa t00sa moved this to In flight in Development Tracker Jul 10, 2025
@t00sa t00sa requested review from a team, Pierre-siddall and MatthewHambley and removed request for a team July 10, 2025 08:22
@yaswant yaswant added this to the vn2.0 milestone Jul 10, 2025
@hiker
Copy link
Collaborator Author
hiker commented Jul 10, 2025

I still had way too many merging problems :( I hope I got them all sorted out correctly. A few comments and questions:

  1. I had to modify the github workflow settings in 30a501b ... does anyone know if this is still required? My guess would be not, but I seem to remember that there were some issues with that? I would suspect that this can/should be removed now?
  2. While fi 8000 xing things, I also refactored the code to remove change_exec_name, which fixes Remove function to replace name of executable #370.
  3. I've removed two tests in test_linker - that's a totally failure of code review (and I can write this, since I reviewed it :) ). The tests were
    1. too far intended, hence never actually executed
    2. used self, so looks like they were supposed to be in a class? But de-facto they were sub-definitions in another test only and not execited.
    3. The function they are testing doesn't even exist at all :(

I have no idea what happened with 3. It looks a bit like a bad merge somewhere? I have had git getting confused quite a bit, but I didn't check any further. Removing library definitions is de-facto not necessary (if they are not needed they don't matter, if they are needed, you don't want to delete them - if at all, you replace them, which you can). So, I think that's KISS :)

@hiker hiker marked this pull request as ready for review July 10, 2025 14:32
@hiker
Copy link
Collaborator Author
hiker commented Jul 10, 2025

@yaswant , @MatthewHambley - I can't select the reviewer group, please assign someone :)

@hiker hiker removed the Blocked Blocked by another issue label Jul 10, 2025
Copy link
Collaborator
@MatthewHambley MatthewHambley left a comment

Choose a reason for hiding this comment

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

Some minor changes and some information needed.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is this change modifying workflows?

@@ -68,6 +69,16 @@ def check_available(self) -> bool:
return False
return True

def set_full_path(self, full_path: str):
Copy link
Collaborator

Choose a reason for hiding this comment

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

If we're dealing with paths we might use the Path class.

@@ -40,6 +40,7 @@ def __init__(self, name: str, exec_name: Union[str, Path],
self._logger = logging.getLogger(__name__)
self._name = name
self._exec_name = str(exec_name)
self._full_path = ""
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not combine _exec_name and _full_path into an _executable: Path which con hold a relative or absolute path. Then when the executable name is needed use _executable.name.

This would save having to do if self._full_path... choices later.

Comment on lines -94 to -103
def change_exec_name(self, exec_name: str):
'''Changes the name of the executable This function should in general
not be used (typically it is better to create a new tool instead). The
function is only provided to support CompilerWrapper (like mpif90),
which need all parameters from the original compiler, but call the
wrapper. The name of the compiler will be changed just before
compilation, and then set back to its original value
'''
self._exec_name = exec_name

Copy link
Collaborator

Choose a reason for hiding this comment

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

Happy to see the back of change_exec_name, never a fan of that.

Comment on lines +180 to +185
path_name = Path(name)
full_path = None
if path_name.is_absolute():
# We have a full path:
name = path_name.name
full_path = str(path_name)
Copy link
Collaborator

Choose a reason for hiding this comment

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

At least some of this feels like it should be in the tool itself, as noted above.

Comment on lines +41 to +48
assert len(recwarn) == 2
user_warning = recwarn.pop(UserWarning)
assert ("_metric_send_conn not set, cannot send metrics" in
str(user_warning.message))
dep_warning = recwarn.pop(DeprecationWarning)
assert ("RootIncFiles is deprecated as .inc files are due to be "
"removed." in str(dep_warning.message))

Copy link
Collaborator

Choose a reason for hiding this comment

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

I was not aware of recwarn but I think it is neater than the slightly clumsy with warns(... syntax.

In the case of these warnings where we are testing for the presence of almost the whole string and there is no variable component (such as a filename) in the string we should probably test for equality. i.e. assert user_warning.message == "...".

@@ -22,7 +22,7 @@ class TestRootIncFiles:
"""
Tests include files are handled correctly.
"""
def test_vanilla(self, tmp_path: Path) -> None:
def test_vanilla(self, tmp_path: Path, recwarn) -> None:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just checked the documentation and the type is recwarn: WarningsRecord.

'''
cc = Compiler("gcc", "gcc", "gnu", version_regex="some_regex",
category=Category.C_COMPILER, openmp_flag="-fopenmp")
assert cc._exec_name == "gcc"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Tests looking at "private" state is concerning. What's going on here?

['mpicc', '--version']
]


def test_version_consistency(stub_c_compiler: CCompiler,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I take it this test is no longer relevant. Are these the teste mentioned in the comment trail? If not a quick explanation of why they are removed would be handy.

fake_process.register(['ifort', '-V'], stdout='ifort (IFORT) 1.2.3 foo')
fake_process.register(['icc', '--version'], stdout='icc (ICC) 1.2.3 foo')
fake_process.register(['ifort', '--version'],
stdout='ifort (IFORT) 1.2.3 foo')
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's getting increasingly hard to find information on the ifort/icc compilers but I did some checking and -V is the correct argument for getting what Intel call "the logo" which is the version information.

What was the reason for changing this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Priority Indicate an issue that should be done in the near future. Release Items that are required for the next release
Projects
Status: In flight
Development

Successfully merging this pull request may close these issues.

5 participants
0