Repository navigation
Refactor iree_bytecode_module and iree_c_module static lib support - #10238
Conversation
Add STATIC_LIB_PATH option instead of parsing the compiler flags
| endif() | ||
| endforeach(_FLAG) | ||
| if(_RULE_STATIC_LIB_PATH) | ||
| list(APPEND _ARGS "--iree-hal-target-backends=llvm-cpu") |
There was a problem hiding this comment.
Huh I missed that we weren't already passing the backend as an explicit cmake arg. That makes this way of doing things a bit more weird (because now if I switch from non-static to static lib I drop the target arg). I still think it's better though
There was a problem hiding this comment.
I can leave the target backend flag outside of the iree_*_module macro, although in L53 we still want to check the setting condition as
if(_RULE_STATIC_LIB_PATH AND NOT IREE_TARGET_BACKEND_LLVM_CPU)
message(SEND_ERROR "Static library only supports llvm-cpu backend")
endif()
There was a problem hiding this comment.
Oh I wasn't saying change it, necessarily. What you have now and what you had before that last commit are both fine :-) I think the ideal given we're doing things based on backend would be to have the backend as an explicit arg also, but I'm not going to punish you with extra work just because you touched this rule :-P
Match the input arguments for CMake `iree_*_modules` functions.
|
As discussed offline, add the corresponding |
| out_files = [module_name] | ||
| module_flags = ["--output-format=vm-bytecode"] | ||
| if static_lib_path: | ||
| static_header_path = static_lib_path.replace(".o", ".h") | ||
| out_files.extend([static_lib_path, static_header_path]) | ||
| module_flags.extend([ | ||
| "--iree-llvm-link-embedded=false", | ||
| "--iree-llvm-link-static", | ||
| "--iree-llvm-static-library-output-path=$(location %s)" % (static_lib_path), | ||
| ]) | ||
|
|
There was a problem hiding this comment.
Rather than creating a separate variable and then adding it on, just use the single variable "flags" and extend it with the new stuff? I think Starlark does away with some of Python's foot-gun reference semantics so modifying the list passed in shouldn't be a problem (if it is, you can also use += instead of extend/append). Note that this is slightly different than what you have semantically because it adds the rule's flags at the end instead of the beginning. I'm not sure whether that's practically a difference. If it is, it's probably better to leave as you have it with the user-provided flags at the end
| out_files = [module_name] | |
| module_flags = ["--output-format=vm-bytecode"] | |
| if static_lib_path: | |
| static_header_path = static_lib_path.replace(".o", ".h") | |
| out_files.extend([static_lib_path, static_header_path]) | |
| module_flags.extend([ | |
| "--iree-llvm-link-embedded=false", | |
| "--iree-llvm-link-static", | |
| "--iree-llvm-static-library-output-path=$(location %s)" % (static_lib_path), | |
| ]) | |
| out_files = [module_name] | |
| flags.append("--output-format=vm-bytecode") | |
| if static_lib_path: | |
| static_header_path = static_lib_path.replace(".o", ".h") | |
| out_files.extend([static_lib_path, static_header_path]) | |
| flags.extend([ | |
| "--iree-llvm-link-embedded=false", | |
| "--iree-llvm-link-static", | |
| "--iree-llvm-static-library-output-path=$(location %s)" % (static_lib_path), | |
| ]) | |
There was a problem hiding this comment.
buildifier accepts += to replace extend, but it still prefers append over +=. Made the change based on the feedback and the buildifier result.
8def75a to
613a7ff
Compare
Add STATIC_LIB_PATH option instead of parsing the compiler flags