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

*.ldscript file will not propagate to the final step when linking #716

Closed
chin33z opened this issue Dec 15, 2015 · 8 comments
Closed

*.ldscript file will not propagate to the final step when linking #716

chin33z opened this issue Dec 15, 2015 · 8 comments
Labels
P3 We're not considering working on this, but happy to review a PR. (No assignee) stale Issues or PRs that are stale (no activity for 30 days) team-Rules-CPP Issues for C++ rules type: bug

Comments

@chin33z
Copy link

chin33z commented Dec 15, 2015

cc_binary(
    name = "hello",
    srcs = ["main.c"],
    deps = [":lib"]  <----":lib.ldscript" to add here
)

cc_library(
    name = "lib",
    srcs = ["lib.c"],
    linkopts = ["-Wl,--version-script", ":lib.ldscript"],
    deps = [":lib.ldscript"],
)

Assume all files were placed & edited properly.

This will be fine :
$> bazel build //:lib

This will cause gcc error (lib.ldscript: No such file or directory) :
$> bazel build //:hello

However, if I add ":lib.ldscript" to the deps of "hello". I will not get the error.
But from encapsulated perspective, "hello" should not take care of this information.(The linker script is for "lib" only)

I guess this is because Bazel link all the objects/files in th last steps & the *.ldscript in deps is not propagated to the cc_binary(hello) when linking.

Is this a bug or WAD? Thanks.

@chin33z chin33z changed the title *.ldscript file will not propagate to the final steps when linking *.ldscript file will not propagate to the final step when linking Dec 15, 2015
@ulfjack
Copy link
Contributor

ulfjack commented Dec 15, 2015

It would help if you could show the libldscript rule. I think the most
likely reason is a file extension mismatch - we require linker scripts to
end with ".ld", ".lds", or ".ldscript".

On Tue, Dec 15, 2015 at 5:26 AM, David Hu notifications@github.com wrote:

cc_binary(
name = "hello",
srcs = ["mainc"],
deps = [":lib"] <----":libldscript" to add here
)

cc_library(
name = "lib",
srcs = ["libc"],
linkopts = ["-Wl,--version-script", ":libldscript"],
deps = [":libldscript"],
)

Assume all files were located properly

This will be fine :
$> bazel build //:lib

This will cause gcc error (libldscript: No such file or directory) :
$> bazel build //:hello

However, if I add ":libldscript" to the deps of "hello" I will not get
the error
But from modularized perspective, "hello" should not take care of this
information

I guess this is because Bazel link all the objects/files in th last steps
& the *ldscript in deps is not propagated to the cc_binary(hello) when
linking

Is this a bug or WAD? Thanks


Reply to this email directly or view it on GitHub
#716.

@chin33z
Copy link
Author

chin33z commented Dec 15, 2015

lib.ldscript content:

{
  global: *;
};

I know the file extension requirement in deps (*.ld, *lds, *.ldscript).
And I think the problem is not the content of the linker script.

@ulfjack
Copy link
Contributor

ulfjack commented Dec 15, 2015

In the email I got, it said ":libldscript" not ":lib.ldscript". Well, it does sound like a bug.

@chin33z
Copy link
Author

chin33z commented Dec 15, 2015

It does behave weird for me. I think the "-Wl,--version-script" argument should only present when linking the "lib". However, it shown up when "hello" is linked. Thus, the lib.ldscript is not in the sandbox at that moment.(I guess)

@dslomov dslomov added type: bug P2 We'll consider working on this in future. (Assignee optional) Native rules (Java / C++ / Python) labels Dec 15, 2015
@dslomov dslomov assigned dslomov and philwo and unassigned dslomov Dec 15, 2015
@ulfjack ulfjack added P3 We're not considering working on this, but happy to review a PR. (No assignee) and removed P2 We'll consider working on this in future. (Assignee optional) labels Jun 15, 2016
@ulfjack ulfjack added this to the 1.0 milestone Jun 15, 2016
@burkpojken
Copy link

Hi!
Is it possible to push for this feature to be implemented earlier than 1.0??
Or even make it more generic to be able to add any type of target as a dependency (or e.g. tools = [":myLinkscript"]) that then can be used with $location in e.g. linkopts?

RyRose added a commit to RyRose/smouth-os that referenced this issue Nov 20, 2017
Moved the linker script dependency to a dependency of i386. Added
--spawn_strategy=standalone to the qemu.sh script. Unfortunately, there
is a bug in bazel seen here,
bazelbuild/bazel#716, that requires sandboxing
to be disabled to allow the linker script dependency to persist to the
main kernel dependency. It's not ideal but if they ever fix this bug,
the code as is should function with sandboxing.
@hlopko
Copy link
Member

hlopko commented Jul 19, 2018

CC @oquenchil

@cpsauer
Copy link
Contributor

cpsauer commented Mar 30, 2021

FWIW, I'm seeing this work correctly when used a little differently.

The specific case: I'm passing "-Wl,--version-script,$(location example.ldscript)" into a cc_library's linkopts, and seeing things get compiled correctly by an android_binary that indirectly depends on it.

@sgowroji sgowroji added the stale Issues or PRs that are stale (no activity for 30 days) label Feb 16, 2023
@sgowroji
Copy link
Member

Hi there! We're doing a clean up of old issues and will be closing this one. Please reopen if you’d like to discuss anything further. We’ll respond as soon as we have the bandwidth/resources to do so.

@sgowroji sgowroji closed this as not planned Won't fix, can't repro, duplicate, stale Feb 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P3 We're not considering working on this, but happy to review a PR. (No assignee) stale Issues or PRs that are stale (no activity for 30 days) team-Rules-CPP Issues for C++ rules type: bug
Projects
None yet
Development

No branches or pull requests

10 participants