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

Build fails with customized cargo target dir #1543

Open
ksqsf opened this issue Sep 27, 2019 · 6 comments
Open

Build fails with customized cargo target dir #1543

ksqsf opened this issue Sep 27, 2019 · 6 comments

Comments

@ksqsf
Copy link

ksqsf commented Sep 27, 2019

I changed the default target dir in ~/.cargo/config

[build]
target-dir = "~/.cache/cargo"

remacs seems to use the default path regardless of this setting.

  CCLD     etags
clang: error: no such file or directory: '../rust_src/target/release/libremacs_lib.a'
@ksqsf
Copy link
Author

ksqsf commented Sep 27, 2019

To fix it:

configure.ac

LDFLAGS_REMACS="-L`(cd rust_src && cargo metadata --format-version=1 | jq -r .target_directory)`/\${CARGO_BUILD_DIR}"

lib-src/Makefile.in

RUST_ARCHIVE = `(cd ../rust_src && cargo metadata --format-version=1 | jq -r .target_directory)`/$(CARGO_BUILD_DIR)/$(REMACSLIB_NAME)

This depends on jq.

@shaleh
Copy link
Collaborator

shaleh commented Sep 27, 2019

Can you link to some upstream docs? This seems like a lot to ask every project to bend to the user's settings. Shouldn't cargo handle this for us?

@ksqsf
Copy link
Author

ksqsf commented Sep 27, 2019

My comment above uses cargo metadata which is handled by cargo itself, so this should be the expected solution. I don't know how to reliably and portably extract the target_directory field from the returned json though.

edit: and cargo does handle this. The problem is that remacs hard-coded the target dir path.

@shaleh
Copy link
Collaborator

shaleh commented Sep 28, 2019

Right, what I am asking is why does our project need to change to handle this? Shouldn't cargo know where to write files based on its own config? Are we doing something out of the ordinary?

@ksqsf
Copy link
Author

ksqsf commented Sep 28, 2019

The target dir is hardcoded to be toplevel/rust_src/target. This leads to the very compilation error I encountered.

So it's like, cargo places the archive at ~/.cache/cargo/release/libwhatever.a as intended, but the linker looks for it under $toplevel/rust_src/target/release/.

@shaleh
Copy link
Collaborator

shaleh commented Sep 30, 2019

Got it. Thank you.

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

No branches or pull requests

2 participants