Skip to content

llc only supports one input file #36

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 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 19 additions & 17 deletions cmake/LLVMIRUtil.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -753,14 +753,26 @@ function(llvmir_attach_obj_target)
list(APPEND IN_FULL_LLVMIR_FILES "${IN_LLVMIR_DIR}/${IN_LLVMIR_FILE}")
endforeach()

set(FULL_OUT_LLVMIR_FILE "${WORK_DIR}/${TRGT}.o")
if(SHORT_NAME)
Copy link
Owner

Choose a reason for hiding this comment

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

Isn't SHORT_NAME still useful for the multiple output files generated by the changes in your PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In my project it worked fine without it, so I assumed that I could just remove it.

Copy link
Owner

Choose a reason for hiding this comment

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

Can you please reintroduce it and check that your project still works?
Just because it's not needed in your configuration doesn't mean that wasn't introduced for a reason initially.

set(FULL_OUT_LLVMIR_FILE "${WORK_DIR}/${SHORT_NAME}.o")
endif()
get_filename_component(OUT_LLVMIR_FILE ${FULL_OUT_LLVMIR_FILE} NAME)
foreach(IN_LLVMIR_FILE ${IN_FULL_LLVMIR_FILES})
get_filename_component(OUTFILE ${IN_LLVMIR_FILE} NAME_WE)
set(OUT_LLVMIR_FILE "${OUTFILE}.o")
set(FULL_OUT_LLVMIR_FILE "${WORK_DIR}/${OUT_LLVMIR_FILE}")

list(APPEND OUT_LLVMIR_FILES ${OUT_LLVMIR_FILE})
list(APPEND FULL_OUT_LLVMIR_FILES ${FULL_OUT_LLVMIR_FILE})
add_custom_command(OUTPUT ${FULL_OUT_LLVMIR_FILE}
COMMAND llc
ARGS
-filetype=obj
-relocation-model=pic
Copy link
Owner

Choose a reason for hiding this comment

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

why do we need this flag here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added this flag because the compiler complained in my real project that I needed to recompile with -fPIC.

Copy link
Owner

Choose a reason for hiding this comment

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

I'd rather not have project-specific options hardcoded like this.
This command handles other args and passes them unaltered using ${LLVMIR_ATTACH_UNPARSED_ARGUMENTS}.

Can you please try your project with defining that flag in your CMakeLists.txt?

-o=${FULL_OUT_LLVMIR_FILE}
${LLVMIR_ATTACH_UNPARSED_ARGUMENTS}
${IN_LLVMIR_FILE}
DEPENDS ${IN_LLVMIR_FILE}
COMMENT "Generating object ${OUT_LLVMIR_FILE}"
VERBATIM)

list(APPEND OUT_LLVMIR_FILES ${OUT_LLVMIR_FILE})
list(APPEND FULL_OUT_LLVMIR_FILES ${FULL_OUT_LLVMIR_FILE})
endforeach()

# setup custom target
add_custom_target(${TRGT} DEPENDS ${FULL_OUT_LLVMIR_FILES})
Expand All @@ -786,16 +798,6 @@ function(llvmir_attach_obj_target)
set_property(TARGET ${TRGT} PROPERTY EXCLUDE_FROM_ALL On)
set_property(TARGET ${TRGT} PROPERTY LLVMIR_SHORT_NAME ${SHORT_NAME})

add_custom_command(OUTPUT ${FULL_OUT_LLVMIR_FILE}
COMMAND llc
ARGS
-filetype=obj
${LLVMIR_ATTACH_UNPARSED_ARGUMENTS}
-o ${FULL_OUT_LLVMIR_FILE} ${IN_FULL_LLVMIR_FILES}
DEPENDS ${IN_FULL_LLVMIR_FILES}
COMMENT "Generating object ${OUT_LLVMIR_FILE}"
VERBATIM)

## postamble
endfunction()

Expand Down