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

When I cross compile the example , Bazel does not produce shared libraries #7637

Closed
darbee opened this issue Mar 6, 2019 · 4 comments
Closed
Labels
P4 This is either out of scope or we don't have bandwidth to review a PR. (No assignee) team-Rules-CPP Issues for C++ rules type: support / not a bug (process) under investigation

Comments

@darbee
Copy link

darbee commented Mar 6, 2019

When I cross compile the example using qnx , Bazel does not produce shared libraries. Instead, in the bazel-bin directory, there are only static libraries,(.a), not any dynamic libraries(.so). If I do not use cross compile , I can produce dynamic libraries.

@dslomov dslomov added team-Rules-CPP Issues for C++ rules untriaged labels Mar 8, 2019
@hlopko
Copy link
Member

hlopko commented Mar 14, 2019

Oh we'll need more information than this (most of these questions are in the default issue template) to help.

  1. What is the platform you're running Bazel on?
  2. What version of Bazel do you run?
  3. What example do you build? Can you share the full Bazel command? A repro repo?
  4. What does it mean to cross-compile in your case? Which C++ toolchain do you use? What is the value of --crosstool_top and --cpu and --compiler Bazel options?
  5. If you use Bazel's autoconfigured C++ toolchain, what compilers do you have installed, what environment variables do you set? Do you set CC?

@hlopko hlopko added P4 This is either out of scope or we don't have bandwidth to review a PR. (No assignee) type: support / not a bug (process) under investigation and removed untriaged labels Mar 14, 2019
@darbee
Copy link
Author

darbee commented Mar 20, 2019

HI sorry to reply late, I run bazel on
1.x86_64 platform, and the
2. version is 0.22.0.
3. the example is at
https://github.com/bazelbuild/examples/tree/master/cpp-tutorial/stage3
and I follow the instruction at
https://github.com/bazelbuild/bazel/wiki/Building-with-a-custom-toolchain/581fe11cea8396ce125c879db9160d8368a5957e

  1. the target cpu is aarch64, and the system is qnx
  2. I find the the solution: We need add linking_mode_flags { mode: DYNAMIC } to the CROSSTOOL file

There is another proble here, If I use bazel version 0.5.3, I report some error in CROSSTOOL file, for example:
java.io.IOException: Could not read the crosstool configuration file 'CROSSTOOL file /home/dabin/Documents/qnx-compiler/CROSSTOOL', because of an incomplete protocol buffer (Message missing required fields: default_target_cpu).

When I add default_target_cpu:"aarch64"

I report error
Could not read the crosstool configuration file 'CROSSTOOL file /home/dabin/qnx-compiler/CROSSTOOL', because of a parser error (9:3: Input contains unknown fields and/or extensions: 9:3: com.google.devtools.build.lib.view.config.crosstool.CToolchain.default_target_cpu).

@hlopko
Copy link
Member

hlopko commented Mar 20, 2019

  1. The better solution is to add:

    feature { name: "supports_dynamic_linker" enabled: "true" }

  2. A lot has changed since 0.5.3, don't use the same toolchain for both Bazel version. Have 2 separate toolchains.

  3. Very soon we're flipping incompatible_disable_legacy_crosstool_fields: Disable legacy crosstool fields #6861 and incompatible_disable_crosstool_file: Disable loading data from CROSSTOOL files #7320, be sure to check out the migration instructions. Also docs on bazel.build have been updated.

Cool, glad this got resolved. Happy hacking!

@hlopko hlopko closed this as completed Mar 20, 2019
@hlopko
Copy link
Member

hlopko commented Mar 20, 2019

(edited the link to the issue)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P4 This is either out of scope or we don't have bandwidth to review a PR. (No assignee) team-Rules-CPP Issues for C++ rules type: support / not a bug (process) under investigation
Projects
None yet
Development

No branches or pull requests

3 participants