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

llc only supports one input file #36

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

otsmr
Copy link
Contributor

@otsmr otsmr commented Oct 30, 2023

When the target library is compiled to a static library with the following CMAKE options:

add_library(testbase STATIC ${SOURCE_FILES})
llvmir_attach_bc_target(testbase_bc testbase)
llvmir_attach_opt_pass_target(testbase_opt testbase_bc -load-pass-plugin=${LLVM_PASS_CTRACE} -passes=ctrace)
llvmir_attach_obj_target(testbase_obj testbase_opt)
llvmir_attach_library(testbase_instrumented testbase_obj STATIC)

I got the following error message:

FAILED: llvm-ir/testbase_obj/testbase_obj.o /[...]/build/llvm-ir/testbase_obj/testbase_obj.o
cd /[...]/build && llc -filetype=obj -o /[...]/build/llvm-ir/testbase_obj/testbase_obj.o /[...]/build/llvm-ir/testbase_opt/Test1.bc /[...]/build/llvm-ir/testbase_opt/Test2.bc /[...]/build/llvm-ir/testbase_opt/Test3.bc /[...]/build/llvm-ir/testbase_opt/Test4.bc
llc: Too many positional arguments specified!
Can specify at most 1 positional arguments: See: llc --help
ninja: build stopped: subcommand failed.

The problem is that LLC only supports one input file. This PR fixes this issue by going over each bc file separately.

Copy link
Owner

@compor compor left a comment

Choose a reason for hiding this comment

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

Could you add a minimal example that reproduces the issue? You can add it as example04 in the top-level directory.

I plan to write some basic tests and move the examples to form a small test suite.

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?

@@ -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.

@compor compor assigned compor and otsmr and unassigned compor Oct 30, 2023
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.

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?

@@ -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.

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.

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

Successfully merging this pull request may close these issues.

2 participants