-
Notifications
You must be signed in to change notification settings - Fork 89
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
embed.cmake: add support for Windows resource file #2330
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #2330 +/- ##
==========================================
Coverage ? 91.36%
==========================================
Files ? 440
Lines ? 16547
Branches ? 0
==========================================
Hits ? 15118
Misses ? 1429
Partials ? 0 |
This build is not recommended to merge 🔴 |
❌agentmodel: ERROR - check error outputTraceback (most recent call last):File "/src/AMDMIGraphX/tools/accuracy/accuracy_checker.py", line 336, in main() File "/src/AMDMIGraphX/tools/accuracy/accuracy_checker.py", line 254, in main pred_migx = np.array(model.run(params)[-1]) RuntimeError: /src/AMDMIGraphX/src/targets/gpu/device/include/migraphx/gpu/device/visit.hpp:140: hip_visit_views_impl: Ranks must be the same 🔴bert_base_cased_fp16: FAILED: MIGraphX is not within tolerance - check verbose output🔴bert_large_uncased_fp16: FAILED: MIGraphX is not within tolerance - check verbose output🔴distilgpt2_fp16: FAILED: MIGraphX is not within tolerance - check verbose output |
|
||
option(EMBED_USE_LD "Use ld to embed data files" OFF) |
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.
We shouldn't remove this option.
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.
The technique with LD on Linux is the same as RC on Windows. I changed EMBED_USE_LD
to EMBED_USE_RESOURCES
because, in both cases, the literature refers to both techniques as embedding resource files in program binary. Here is the example: https://atwillys.de/content/cc/embedding-resource-files-in-a-c-plus-plus-program-binary-on-linux-unix/?lang=en. I can easily find tonnes more. We only need one option to control resources or *.cpp
files. It makes no sense to have both and expose EMBED_USE_LD
on Windows and EMBOED_USE_RC
on Linux.
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.
The technique with LD on Linux is the same as RC on Windows. I changed EMBED_USE_LD to EMBED_USE_RESOURCES because, in both cases, the literature refers to both techniques as embedding resource files in program binary.
The name is the technique used for embedding the resource. We are embedding the resource when we use the C arrays as well, so the EMBED_USE_RESOURCES
flag would apply there as well, so it doesnt make sense.
It makes no sense to have both and expose EMBED_USE_LD on Windows and EMBOED_USE_RC on Linux.
I would prefer the two flags because there are other techniques to embed resources as well(such as using #embed
) so I would prefer to have a flag to specify the technique being used to embed the resources.
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.
I prefer a single option for LD and RC (e.g., EMBED_USE_BINARY
or EMBED_USE_NATIVE
or EMBED_USE_OS_NATIVE
) and separate for #embed
when we switch to C++23 (e.g. EMBED_USE_CXX_EMBED
or EMBED_USE_CXX
or EMBED_USE_CXX_NATIVE
) or something like that. Two flags for LD and RC would result in different Linux and Windows building instructions. One cannot use LD on Windows and RC on Linux. I prefer to keep them the same for both OSes.
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.
We should probably have one EMBED_USE
variable that can be set to EMBED_USE=RC
for windows resource files, EMBED_USE=LD
for gnu linker, and EMBED_USE=CArrays
for the carrays version.
We can also use set_property(CACHE EMBED_USE PROPERTY STRINGS "LD;CArrays")
to set the options for linux, so in cmake gui(or tui) you can select the option you want.
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.
Done
cmake/Embed.cmake
Outdated
endif() | ||
|
||
if(NOT WIN32 AND EMBED_USE_RESOURCES) | ||
find_program(EMBED_LD ld) |
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 are we searching for ld
when EMBED_USE_RESOURCES
is enabled on linux? This should be an error.
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.
Because one may turn it on Linux, see my comment above.
endfunction() | ||
|
||
function(add_embed_library EMBED_NAME) | ||
set(options) | ||
set(oneValueArgs RELATIVE) | ||
set(multiValueArgs) |
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.
Dont remove these extra variables.
cmake/Embed.cmake
Outdated
set(oneValueArgs RELATIVE) | ||
set(multiValueArgs) | ||
cmake_parse_arguments(PARSE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) | ||
set(oneValueArgs BASE_DIRECTORY) |
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 is RELATIVE
removed? We need to specify which directory we want the paths to relative to.
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.
I changed RELATIVE
to BASE_DIRECTORY
to align with the cmake_path()
command naming to make it cleaner to read cmake_path(RELATIVE_PATH <path-var> BASE_DIRECTORY <input> ...)
.
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.
It uses RELATIVE
to match file(GLOB)
command. I dont think cmake_path
makes sense here.
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.
I changed file(GLOB)
to cmake_path()
for making relative paths. However, I don't care much about the name. If that is the only obstacle blocking this PR and you want the name to be RELATIVE
, I make it RELATIVE
again.
This PR introduces the support of Windows resource files to Embed.cmake. It is ON by default on Windows, and when it is OFF *.cpp files will be used. The same applies to Linux - ON -> *.o (LD) or OFF -> *.cpp . This PR fixes building resources on Linux with ld and objcopy commands.
This PR introduces the support of Windows resource files to
Embed.cmake
. It isON
by default on Windows, and when it isOFF
*.cpp
files will be used. The same applies to Linux -ON
->*.o
(LD) orOFF
->*.cpp
.This PR fixes building resources on Linux with
ld
andobjcopy
commands.