Skip to content

Fix cxx flags dir#5249

Merged
voodoos merged 6 commits intoocaml:mainfrom
voodoos:fix-cxx-flags-dir
Dec 2, 2021
Merged

Fix cxx flags dir#5249
voodoos merged 6 commits intoocaml:mainfrom
voodoos:fix-cxx-flags-dir

Conversation

@voodoos
Copy link
Copy Markdown
Collaborator

@voodoos voodoos commented Nov 30, 2021

Default C++ flags require compiler detection and need the path to the build directory for that.
Previously the wrong path was sometime given. This PR fixes the issue and changed the signature of the function to require the context instead of the build path.

I discovered this problem when rebasing #4846

CC @recoules can you confirm that it fixes #4847 ? And maybe test it in a more realist setting ?

@voodoos voodoos requested a review from a user November 30, 2021 15:43
@voodoos voodoos added this to the 3.0.0 milestone Nov 30, 2021
@voodoos
Copy link
Copy Markdown
Collaborator Author

voodoos commented Nov 30, 2021

CC @recoules can you confirm that it fixes #4847 ? And maybe test it in a more realist setting ?

Or maybe later... There is an issue when the compiler is gcc apparently, I will have a look. 

Should be fixed.

@@ -0,0 +1,2 @@
Building a cxx library should run ocamlmklib with "-lstdc++".
$ dune build
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

How should I check that this test succeeds?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

If it fails a bunch of undefined symbols such as std::__1::cout errors are printed by the linker.
I will make that clear in the test description. Also the flag is not always -stdc++, it is -lc++ for clang.

Also there is no specific link flag for c++ compilation with MSVC so this test won't fail on windows.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Ack. I'm not sure we run the testsuite on Windows BTW.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Just one last thing: I was looking at the commits individually. I was expecting to see the test fail at first and then observe subsequent commits fix it, but it seems that it was succeeding from the start. Is that the case?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yes they are indeed failing but the error message was not promoted, do you want me to edit it ?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

That's alright, I just wanted to check it was the case. For next time, please do promote it. It's good practice to first demonstrate the problem and then demonstrate that it is fixed. Plus it's good if the testsuite passes for each commit.

Copy link
Copy Markdown

@ghost ghost left a comment

Choose a reason for hiding this comment

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

Looks good!

@recoules
Copy link
Copy Markdown
Contributor

recoules commented Dec 2, 2021

CC @recoules can you confirm that it fixes #4847 ? And maybe test it in a more realist setting ?

Or maybe later... There is an issue when the compiler is gcc apparently, I will have a look.

Should be fixed.

It worked for my original use case.

recoules and others added 6 commits December 2, 2021 17:31
Signed-off-by: Ulysse Gérard <thevoodoos@gmail.com>
Signed-off-by: Ulysse Gérard <thevoodoos@gmail.com>
This help ensure the path is correct at is is expected to be the build path.

Signed-off-by: Ulysse Gérard <thevoodoos@gmail.com>
and remove commented rules

Signed-off-by: Ulysse Gérard <thevoodoos@gmail.com>
Signed-off-by: Ulysse Gérard <thevoodoos@gmail.com>
Signed-off-by: Ulysse Gérard <thevoodoos@gmail.com>
@voodoos voodoos merged commit 6005ed9 into ocaml:main Dec 2, 2021
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.

foreign_library with c++ files does not add stdc++ dependency

2 participants