-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Allow compile_to_multitarget() to emit object files #5183
Conversation
Review ping |
Looks reasonable to me, but Alex's review is more important. |
I suppose it's impossible at this point to make the names consistent between n=1 and n>1, but other than that, my only question is about the extra work of changing "-" to "_". I'm not sure why that's necessary. |
src/Module.cpp
Outdated
@@ -830,7 +833,7 @@ void compile_multitarget(const std::string &fn_name, | |||
} | |||
|
|||
// Each sub-target has a function name that is the 'real' name plus a suffix | |||
std::string suffix = "_" + replace_all(target.to_string(), "-", "_"); | |||
std::string suffix = "_" + replace_all(target_label, "-", "_"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we change "-" to "_" here? What's wrong with just doing "-" everywhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reasons likely lost to the mists of time now. But it's been that way for a while and some downstream systems are forced to rely on it (eg Bazel, in which the build system must know exact names for all files produced), so if we changed it here we'd have to change some downstream users, potentially. Not likely a big deal but also not a big deal to keep it this way. (For outputs that are embedded in a .a
file it doesn't matter, but for other outputs, like .s
files, it does.)
I think I want to get #5186 working before we land this to make sure I don't need any further changes here. |
No, impossible at all -- it's just a policy decision. We could declare that |
OK, I have changed it so that (I did not change the underscore-vs-hyphen code at this point.) PTAL. |
Ok, I will update #5186 |
Looks like the |
whoops, fix pushed |
Double checking: This doesn't change the filename resulting from compile_to_object, right? |
Should not change that. |
Hm, this still is a little ticklish: it doesn't change
I'm inclined to do the first. Anyone have strong feelings otherwise? |
Yeah, that's the case I was concerned about. I guess I assumed it went through compile_to_object. I feel strongly that we should preserve the existing behavior of -e o so as to not break peoples' builds, and so that you don't have to think about multitarget if it's not relevant to you. Can't we just make -e o equivalent to compile_to_object for single-target builds? |
Sure. That's exactly what it was before the latest change I pushed (at Alex's request). Having a symmetry for the object-file outputs (so that they have a uniform naming convention regardless of whether you generate one or more-than one) is appealing. But it is a behavioral change. To be honest, I don't really have a dog in this fight (if I had my druthers I'd require us to always output (FYI: I updated the apps/linear_algebra Makefile to use static_library instead, which seems like a safe and good change regardless of what we decide here.) |
Amusingly, people might be using -e o instead of static libraries specifically because build systems treat generated libraries as second class |
I also like your option 3: Refusing to do multi-target with -e object, and instead requiring -e objects or -e object_bundle or something. Something that conveys that it's multiple things. |
If, by "amusingly", you mean "tragically", then yes. (Why |
This is fine.
While I do like the Halide/cmake/HalideGeneratorHelpers.cmake Lines 142 to 151 in dfab2a2
where |
Something about the I'm going to leave this PR as-is for tonight and ponder overnight. I welcome any more thoughts people have here. |
I'm perfectly fine special casing for n=1 since I have to special case for n>1 anyway on account of the |
Hrm, an excellent point. OK, I'll do some selective reverting to go back to the previous behavior. |
This reverts commit 01c15b4.
OK, I have reverted the relevant bits of code, so single-target object files now produce the same (unadorned) filename that they always did. PTAL. Re: the swapping of _ and - in the filenames, I can be persuaded to make that change if there is a consensus in favor of it, but I'm reluctant to do so otherwise, as it's arguably an API change. @abadams any thoughts? |
I think the replacement only applies to the suffixes in multi-target, right? I'm not really sure on why those were replaced. I don't have a strong opinion on it. Are there file-systems where hyphens are a no-no? |
None that I'm aware of. |
The question isn't so much "why did we do this in the first place", and more "is there a compelling reason to change it now, and risk breaking downstream build systems that rely on the current naming" |
I don't consider the names of the object files inside the static library to be part of the interface - wouldn't you have to be doing something pretty weird for that to matter? |
Yes, but Hyrum's Law suggests that someone somewhere is basing their entire career on this decision :-) (I'll try keeping the hyphens and see what breaks.) |
OK, I think all the issues are addressed. PTAL. |
Merging into #5186 now. Need to figure out how I broke WASM then this can land. |
@alexreinking you'll need to mark this as 'changed are addressed' |
I couldn't find that button, so I just hit 'approve' instead 🙃 |
I think this fits the criteria you need. PTAL.
Fixes #5169