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

Habemus Macam #82

Merged
merged 15 commits into from
Aug 17, 2023
Merged

Habemus Macam #82

merged 15 commits into from
Aug 17, 2023

Conversation

jacg
Copy link
Owner

@jacg jacg commented Aug 16, 2023

Closes #15.

The remaining problems against which we were banging our heads recently, were caused by linking multiple versions of libc++, which was caused by the dependencies (G4 and Qt) and the client code using different compiler configurations.

The solution1 is to use the gcc environment rather than the clang one in the flake's devShell. This is only necessary on Darwin, but (for now) it has been changed on Linux too.

The change to gcc breaks the compile-time tests we added recently (which have been removed, to make GHA pass).

Thus, before we can merge this, we have to:

  • Fix failing compile-time tests
  • Revert to clang on Linux

@soleti this has been tested on macOS on Intel, but we do not have access to Apple Silicon, so it would be good if you could check that it works there too.

(Why is the macOS GHA so slow? The one I've been waiting for before submitting this PR, completed on Linux in under 9 minutes, the macOS one chugged along for muuuch longer and then failed spuriously, so I had to restart it. Then it took another 21 minutes.)

Footnotes

  1. This solution is temporary: a fix is in the pipeline upstream.

@soleti
Copy link
Contributor

soleti commented Aug 17, 2023

This looks like it's working on macOS Silicon as well, I am able to run g4-examples/B1.

@jacg
Copy link
Owner Author

jacg commented Aug 17, 2023

@soleti Could you also try the version in the fix-clang-on-darwin branch?

@soleti
Copy link
Contributor

soleti commented Aug 17, 2023

Also works.

@jacg
Copy link
Owner Author

jacg commented Aug 17, 2023

This branch uses clang on Linux, and stdenv (g++) on Darwin. Over in fix-clang-on-darwin we have a version which uses clang on both, but forces the Darwin one to use the same version of libc++ as everything else. The latter is a bit ugly, and should become obsolete once the aforementioned upstream fix lands.

Which one do we prefer?

(I'll add the fix-clang-on-darwin solution here, for archival purposes: we can revert it if we want to stick with what is already here.)

fix-clang-on-darwin should sidestep the compile-time test failures on g++, but maybe we want to take this opportunity to address those. But I wouldn't delay merging this for the sake of fixing compile-time tests on g++.

g++ also spews an absurd amount of warnings.

There is also #17.

@jacg
Copy link
Owner Author

jacg commented Aug 17, 2023

fix-clang-on-darwin should sidestep the compile-time test failures on g++

Apparently, not.

@gonzaponte
Copy link
Collaborator

Which one do we prefer?

Will it still be ugly once the upstream fix is in place?

There is one advantage of keeping g++ on darwin and that's that we don't ignore g++, which we have been doing for a while. As you say:

There is also #17.

But I wouldn't delay merging this for the sake of fixing compile-time tests on g++.

When I get some time I will explore what's going on with that in a separate branch

g++ also spews an absurd amount of warnings.

I guess this has to do with the different interpretations of -Wshadow and so on? If so we will fix it with pragmas like we did before.

@jacg
Copy link
Owner Author

jacg commented Aug 17, 2023

Will it still be ugly once the upstream fix is in place?

Once the upstream fix is in place, it should look exactly like it did before we touched anything, but now it should work.

Currently the clang 16 env on Darwin uses a different version of libc++ from everything else, that's what was causing our problems. After the fix, it should use the same version. IIUC. So our old flake should Just Work.

There is one advantage of keeping g++ on darwin and that's that we don't ignore g++, which we have been doing for a while. As you say:

There is also #17.

I guess we should just add it to GHA.

Off the top of my head, it should be possible to have a default devShell with clang, and a second one with gcc. Then it should be possible to invoke the latter explicitly with something like nix develop .#gcc.

@jacg jacg force-pushed the fix-darwin branch 3 times, most recently from 9daac46 to 8d6d851 Compare August 17, 2023 10:40
@jacg jacg marked this pull request as ready for review August 17, 2023 10:42
@jacg
Copy link
Owner Author

jacg commented Aug 17, 2023

fix-clang-on-darwin should sidestep the compile-time test failures on g++

Apparently, not.

Fixed.

I've left the gcc-on-darwin-clang-on-linux solution in the history, for reference, and replaced it with the patch-clang-on-darwin-to-use-libc++-11 approach.

This avoids using g++, so the compile-time tests now pass.

I suggest that we merge, and deal with g++ related issues (broken compile-time tests, running g++ on GHA) in a separate PR.

Comment on lines 27 to 33
if(APPLE)
target_link_options(Nain4 PRIVATE -undefined dynamic_lookup)
endif()

if(APPLE)
target_link_options(client_exe PRIVATE -undefined dynamic_lookup)
endif()
Copy link
Collaborator

@gonzaponte gonzaponte Aug 17, 2023

Choose a reason for hiding this comment

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

why is Nain4 a target here? this is a client, shouldn't need to mess with Nain4's link options.

Copy link
Owner Author

Choose a reason for hiding this comment

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

I don't know why it's needed, but here is the proof that it is needed.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah, I think we go back again to the issue where fetchcontent grabs the last tag, not the current branch.
#67

Copy link
Owner Author

Choose a reason for hiding this comment

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

Ugh.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we have a commit changing GIT_TAG to your branch to convince ourselves that it's the only issue?

Copy link
Owner Author

Choose a reason for hiding this comment

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

So we'd have to add the if-apple-then-dynamic-lookup gubbins somewhere in there?

Yes, that absolutely needs to go in.

Anything else?

Copy link
Owner Author

Choose a reason for hiding this comment

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

dealing with stupid macos is not a nain4 problem

Unfortunately, in the harsh Real World, it is very much our problem.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I can't think of anything else. Just remember to revert 9d9d552.

We can provide a CMake function for our clients to do if-apple-then-dynamic-lookup more conveniently, but that will probably not work out of the box and deserves its own PR.

Copy link
Collaborator

Choose a reason for hiding this comment

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

The macos build is passing the tests. This means that the networkless recompilation test is not working as expected. My guess is that the command we use to restrict network usage is not working on macos. This means that it's allowed to use the network, fetch the branch and recompile, thus passing the test. But this is not supposed to happen.

Copy link
Collaborator

Choose a reason for hiding this comment

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

And, I can confirm that this is the issue:

sudo: iptables: command not found

client_side_tests/client_subdirectory/CMakeLists.txt Outdated Show resolved Hide resolved
flake.nix Show resolved Hide resolved
@jacg jacg mentioned this pull request Aug 17, 2023
@jacg
Copy link
Owner Author

jacg commented Aug 17, 2023

Do you want to review #86 and/or #84 before I merge them?

I'm bored of having to cancel a duplicate workflow with every push, so it would be good to get at least #86 out of the way quickly.

@gonzaponte
Copy link
Collaborator

There seems to be a linking problem in macOS now?

@jacg
Copy link
Owner Author

jacg commented Aug 17, 2023

Yes, we're going around in circles. Let's summarize:

  1. I needed to add the dynamic-link stuff on apple in the client-side-tests, to make GHA pass
  2. You say that this shouldn't be needed (makes sense).
  3. But it is needed on this branch, because ... oh, I forget the details ... but it's related to Find tag automatically in client-side test #67
  4. I've removed (some (the rest is stuck in an unpushable-until-I-know-more rebase)) of the dynamic-link stuff on apple ...
  5. ... so the workflows fail again ...
  6. ... which is why I said that (elsewhere) that the workflows won't be able to tell us anything sensible about the status of this PR once the apple dynamic linking stuff has been removed.

@gonzaponte
Copy link
Collaborator

But it is needed

I see two options:

  • Now that we understand the failures, we remove the offending lines, merge this PR and tag the new master
  • We merge this PR with the offending lines, tag master at that point and push another commit removing the lines.

I don't have a strong preference.

@jacg
Copy link
Owner Author

jacg commented Aug 17, 2023

What do you consider to be the offending lines? I don't think there are any (unless you're referring to the apple dynamic links in the client-side tests, whose removal I have finally managed to push, so they are not there any more).

If I've got that right, then we

  1. change the tag in the client-side test
  2. merge
  3. tag

done.

@gonzaponte
Copy link
Collaborator

unless you're referring to the apple dynamic links in the client-side tests,

Yes, I was referring to that. I'm not very focused today.

Your plan works. Let's go ahead.

@jacg
Copy link
Owner Author

jacg commented Aug 17, 2023

You or me? I can do it, if you haven't started yet.

@gonzaponte
Copy link
Collaborator

Go for it.

@jacg jacg merged commit 61b7ae5 into master Aug 17, 2023
0 of 4 checks passed
@jacg jacg deleted the fix-darwin branch August 17, 2023 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sort out MacOS problems
3 participants