Skip to content

makedep: add missing libs from pragma(lib) #21390

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 4 commits into
base: master
Choose a base branch
from

Conversation

xoxorwr
Copy link

@xoxorwr xoxorwr commented May 18, 2025

Build tools like xmake depend on that file to be able to implement incremental compilation, it was missing static libraries from pragma(lib) so it resulting in undefined reference errors

@dlang-bot
Copy link
Contributor

Thanks for your pull request and interest in making D better, @xoxorwr! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the coverage diff by visiting the details link of the codecov check)
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

Please see CONTRIBUTING.md for more information.


If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub run digger -- build "master + dmd#21390"

Copy link
Member

@Geod24 Geod24 left a comment

Choose a reason for hiding this comment

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

Could you add a test ?

/**
* Checks if a given path points to file with an extension.
*/
bool hasExtension(char[] path)
Copy link
Member

Choose a reason for hiding this comment

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

You could just use dmd.root.filename : FileName.ext: FileName.ext(path).length.

@@ -247,6 +249,12 @@ void pragmaDeclSemantic(PragmaDeclaration pd, Scope* sc)
ob.writestring(name);
ob.writenl();
}

if (global.params.makeDeps.doOutput && name.hasExtension)
Copy link
Contributor

Choose a reason for hiding this comment

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

hasExtension looks like an arbitrary condition here. The commit message says "Exclude system libs (without ext)" but I don't think that's how it works. kernel32 is a system library on Windows, but I link it with: pragma(lib, "kernel32.lib")

Copy link
Author

Choose a reason for hiding this comment

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

Oh you are right, I guess there is no reason to exclude anything?

Copy link
Contributor

@dkorpel dkorpel May 18, 2025

Choose a reason for hiding this comment

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

Well the thing is libraries are resolved by searching them through a list of library paths, the first of which is the current directory. If it is inside there, it makes sense to add it as a make dependency, but if it's not, then make won't be able to find it so it won't work I think (though I haven't tested this yet).

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh right, this is another problem - resolving the ref to an actual path. I don't think that can really work reliably.

@kinke
Copy link
Contributor

kinke commented May 22, 2025

I don't think this is correct - it's only for linking that a changed external library makes a final binary dirty. When compiling only, a changed library doesn't make the produced object files / static libraries dirty.

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.

5 participants