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

Replace uses of __FILE__ with __FILE_NAME__ in macros #159

Open
vyasr opened this issue Mar 12, 2025 · 3 comments
Open

Replace uses of __FILE__ with __FILE_NAME__ in macros #159

vyasr opened this issue Mar 12, 2025 · 3 comments

Comments

@vyasr
Copy link
Contributor

vyasr commented Mar 12, 2025

The macros that we use currently embed full paths to files. These paths are not necessarily informative, and they have a handful of issues. One is that when building conda packages we wind up embedding various fictitious paths that will not exist on the final machine where the binaries are run. Another issue is that header-only libraries will bring in paths from their source into consuming libraries (e.g. rmm paths wind up inside cudf). Instead of using __FILE__ in macros, we should use __FILE_NAME__, which only prints the filename without the path.

@vyasr
Copy link
Contributor Author

vyasr commented Mar 12, 2025

This came up because of #160 and the specific issues that avoiding __FILE__ would prevent (paths in the host environment).

@jakirkham
Copy link
Member

Agree __FILE__ contains extraneous info that is better truncated to avoid the issues mentioned

Though as discussed offline, it is not uncommon to have multiple files in the same project with the same name (like error.hpp) showing up in multiple places. So having more info about the location (like a relative path) would help make errors/logging messages more informative

@jakirkham
Copy link
Member

Started playing with an alternative approach to remap __FILE__ to use a relative path via compiler flags. Locally this works ok. Put together an initial prototype in PR: rapidsai/rmm#1861

The benefit is we are able to turn our existing absolute paths, which we agree are not as meaningful, into relative paths that keep the important context. Also it means we only need to change our compiler flags, which is a simpler change to roll out across projects

Would be great to have a few people look at this as an option

cc @bdice (as you may be interested in this approach as well)

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

No branches or pull requests

2 participants