Commit Graph

73 Commits

Author SHA1 Message Date
Googler 2f8c04c044 Automatic code cleanup.
PiperOrigin-RevId: 456494185
Change-Id: I9aaefff0976cca2b68646970c8d4675c8e122d19
2022-06-22 06:02:29 -07:00
Christopher Peterson Sauer e0dad88a07 Move examples from deprecated @rules_cc//cc:find_cpp_toolchain -> @bazel_tools//tools/cpp:toolchain_utils.bzl 2022-04-11 16:38:30 -07:00
Christopher Peterson Sauer ab8b67a0ab Move examples from deprecated find_cpp_toolchain -> find_cc_toolchain 2022-04-05 23:58:12 -07:00
Googler 3eaa3c7f88 Remove unnecessary tests from rules_cc
They are now part of the bazelbuild/bazel repository.

Copies buildifier changes contributed by Keith in https://github.com/bazelbuild/rules_cc/pull/128

RELNOTES:none
PiperOrigin-RevId: 435312636
Change-Id: I4d5d2f58d90026c0cdfb5c0a90709de7c28c6ccd
2022-03-17 04:50:16 -07:00
Googler c460f83acb Include more information about configurations in cquery proto formatted outout
1. Add a repeated Configuration field to CqueryResult, and fill in the
checksum, platform, and mnemonic fields.

2. Add a configuration_id field to ConfiguredTarget, and deprecate the existing
configuration field in ConfiguredTarget. The configuration_id field is an index
that points to the Configuration message stored in CqueryResult, following the
same pattern as ActionGraphContainer. This avoids duplicating the same
Configuration message for each ConfiguredTarget.

RELNOTES: Include more information about configurations in cquery proto
formatted output. This deprecates the configuration field of
AnalysisProtosV2.ConfiguredTarget, and adds a new field, configuration_id, to
be used instead.
PiperOrigin-RevId: 429129916
Change-Id: Id048229a6872e6462b67cfe3041cdc907967d7bf
2022-03-17 04:50:09 -07:00
Googler 081771d4a0 Adds providers back temporarily until TF can use head
Adds back providers to cc_shared_library bzl file in rules_cc until TF is using
bazel from head and can use the builtin cc_shared_library version.

RELNOTES:none
PiperOrigin-RevId: 409136047
Change-Id: I53388c18bcbc555e8a3c7edbc5e54634375f051f
2021-11-11 06:50:45 -08:00
Googler 426f721323 Automatic code cleanup.
PiperOrigin-RevId: 407085810
Change-Id: I6cac435d8e0e89f97405c7b3923d1891da78740b
2021-11-02 08:13:14 -07:00
Googler f846566869 Update rules_cc doc references for inclusive-language-fixit-2
PiperOrigin-RevId: 405732925
Change-Id: If700320f2e8f3e45f2fbdf08e945ea94dfe32887
2021-10-26 14:16:20 -07:00
Googler aa7ff810cf Make cc_shared_library use the builtin Starlark version
Eventually, when we are ready to pull out all the other rules to an external
repository cc_shared_library will be moved with the others: cc_library,
cc_binary,...

RELNOTES:none
PiperOrigin-RevId: 401307125
Change-Id: I14f48a7753598eaa4269554e87351a70f75111c2
2021-10-06 12:12:31 -07:00
Googler 68cb652a71 mv BUILD --> BUILD.bazel
PiperOrigin-RevId: 373787065
Change-Id: Ic50705bb2d63b969e939e77150e877f82c2f0c69
2021-05-14 07:51:14 -07:00
Googler 8973704d88 Fix buildifier error in rules_cc
PiperOrigin-RevId: 373438035
Change-Id: I6ff9b0cca80cb5dc7aa597a0ce7fb63d345b1cd9
2021-05-12 13:24:12 -07:00
Copybara-Service 656e045167 Merge pull request #103 from limdor:buildifier_fix
PiperOrigin-RevId: 372517636
Change-Id: I65cae735170b4c017f63ae6fbfd1ec6500e258b0
2021-05-07 02:44:41 -07:00
Xavier Bonaventura 299fce788b Fix buildifier format issue 2021-05-03 20:12:34 +02:00
Copybara-Service c612c9581b Merge pull request #98 from gregestren:master
PiperOrigin-RevId: 366213902
Change-Id: I25281d0487aa1b66b3c81db0fbd723ce3640a49b
2021-04-01 02:45:57 -07:00
Googler 608c7b605f C++: Make permissions check optional in cc_shared_library
The cc_shared_library_permissions mechanism was introduced to add control over
which cc_shared_libraries can export a given cc_library. If the repo is big
enough, the owner of a cc_library might want to prevent someone else in a
different package making their library part of the ABI of a public shared
library because that makes it harder to change the cc_library. This does not
apply accross repositories because a dependant repository can overwrite
anything from a repository dependency anyway.

However, it is becoming more apparent than even though this mechanism should
exist, it should not be enabled by default since most people don't need it. To
enable it pass the flag --//examples:enable_permissions_check=True.

RELNOTES:none
PiperOrigin-RevId: 363171677
Change-Id: I8afb3294806bb3053ee1279c6e9c5355089bccbb
2021-03-16 06:45:21 -07:00
Googler 9544a3eeac Automatic code cleanup.
PiperOrigin-RevId: 362075479
Change-Id: Ib556b478b2e28fa6c35fe493b533035de4916bd0
2021-03-10 09:58:09 -08:00
Googler 88ef31b429 Update rules_cc to use the correct toolchain type (@bazel_tools//tools/cpp:toolchain_type).
PiperOrigin-RevId: 361158816
Change-Id: Ief011b23ddb9bdf3b49237f90fa631b6f916e8de
2021-03-05 09:10:23 -08:00
Googler 25193de8f5 Tests for unknown commit
Adds test for fix to cc_binary in a previous CL which required a Bazel change.

RELNOTES:none
PiperOrigin-RevId: 361152661
Change-Id: Ic7b9cda6636eff6bc231f00f8cdd542e0c88113c
2021-03-05 08:35:07 -08:00
Copybara-Service a3d7068939 Merge pull request #97 from jlaxson:shared-library-double-inheritance-test
PiperOrigin-RevId: 359022952
Change-Id: Iad8c35e8c9b1a187548cf45b3c2c1f231f275bad
2021-02-23 05:03:02 -08:00
Greg Estren f28c5e2e1b Buildifier feedback 2021-02-11 16:15:29 -05:00
Greg Estren 4e7e7f8cbb Typo fixes 2021-02-11 16:07:27 -05:00
Greg Estren 541927eaa0 Add custom C++ toolchain example.
Inspired by https://github.com/bazelbuild/bazel/issues/12942.
2021-02-11 15:53:44 -05:00
John Laxson 8caeb338c9 Test allowing diamond inheritance of shared lib 2021-02-11 10:33:25 -07:00
Copybara-Service 7bd0e49cfb Merge pull request #85 from benjaminp:modern-linking
PiperOrigin-RevId: 341368143
Change-Id: I9b86beeb90f6df6d3564209f1e97ada4ea7bc319
2020-11-09 02:52:23 -08:00
Googler 991eb349bf Internal change
PiperOrigin-RevId: 340301767
Change-Id: Iccab5010d3fd6e77c08fcdc140cdc1e461185b0d
2020-11-02 13:19:59 -08:00
Googler 699ec52985 Internal change
PiperOrigin-RevId: 339925655
Change-Id: Icde35bf6acb72a382e0253fcf9fb5a10d80a5feb
2020-10-30 13:05:57 -07:00
Googler 16ad606329 Internal change
PiperOrigin-RevId: 339887089
Change-Id: Ic511ced72381f847f5d1b9159f299b6e474a47de
2020-10-30 09:41:38 -07:00
Benjamin Peterson 8994fb0fe1 Adjust c archive example for modern linker input API. 2020-10-26 20:31:47 -05:00
Benjamin Peterson 01cf2299fb Fix //examples/test_cc_shared_library:linking_action_test under --incompatible_linkopts_to_linklibs. 2020-10-22 09:59:37 -05:00
Googler f95239adde Update rules_cc to use the toolchain transition.
This is phase 2 of of the switch to toolchain transitions. See https://github.com/bazelbuild/bazel/issues/11584 for details.

PiperOrigin-RevId: 334808134
Change-Id: Ie198b07359d4fd45368755c4cc223e397f0e8fb0
2020-10-01 07:19:37 -07:00
Googler 9ec8187d58 Add docstring to providers to make buildifier happy.
RELNOTES: None.
PiperOrigin-RevId: 334807705
Change-Id: If0c97e6a464126367005143313dc4ddc5b47bdea
2020-10-01 07:16:37 -07:00
Googler 818289e561 Add flags to cc_shared_library for easier debugging
--//examples:incompatible_link_once=False[default = False]
When True, it will be an error to link the same library more than once
unless it has the tag LINKABLE_MORE_THAN_ONCE

--//examples:experimental_debug=True[default = False]
When True, it will generate files listing the exports of each cc_shared_library
and which libraries are linked to it statically.

RELNOTES:none
PiperOrigin-RevId: 311323625
Change-Id: I340cc71965650f7c9dd7ef7fb9656da362021527
2020-05-13 07:24:06 -07:00
Googler 8c31dd406c Change cc_shared_library exports logic.
Changes in this CL:
1. 'exports' attribute renamed to roots
2. Removed restrictions for exporting a rule in a different repository
3. Kept restrictions for rules in the same repository but not in the same
package or subpackages
4. To get around restrictions, instead of the exported_by tag, one can use the
cc_shared_library_permissions rule
5. Added exports_filter that will match libraries in the transitive closure of
a root. Anything matched by the exports_filter will also be exported.
Restrictions as in 4. still apply.

RELNOTES:none
PiperOrigin-RevId: 310547916
Change-Id: I32d8e0d4dd4bcc9c9e92f4ff3c5b2a01564c31b2
2020-05-08 06:35:54 -07:00
Googler 4c3e410486 C++: Fix path checking cc_shared_library
We were returning false when checking whether //foo:bar is under
//:__subpackages__

RELNOTES:none
PiperOrigin-RevId: 307808962
Change-Id: I080e4c239b75c188dae8af89f4b38aa935d92b0d
2020-04-22 07:05:49 -07:00
Googler a74452e910 C++: Optimize cc_shared_library
1. Don't pop from the front of the list being iterated on
2. Don't visit the same node_label more than once

RELNOTES:none
PiperOrigin-RevId: 307610981
Change-Id: I9b35a27a1bdabafbe290d1ff23eeb4659b07d554
2020-04-21 08:38:17 -07:00
Thijs Marinussen d97ac303e5 Stop using the deprecated items parameter. See https://github.com/bazelbuild/bazel/issues/9017 for details 2020-03-30 15:16:33 +02:00
Googler e7f1b2c2e5 Automatic code cleanup.
PiperOrigin-RevId: 299879428
Change-Id: I647d3900c2f26b0b9f587cdbd517ad649cb843d7
2020-03-09 10:48:16 -07:00
Googler 20bff9088b Change the syntax for labels in static_deps and exported_by
The syntax now matches visibility's. This is less confusing than
before, we now have:
 - targets like //foo, //foo:foo or //foo:bar
 - same package match like //foo:__pkg__
 - subpackages like //foo:__subpackages__

RELNOTES:none
PiperOrigin-RevId: 298598757
Change-Id: I6d02cf03c3c67d78998dda27a6529d53d0ef2708
2020-03-03 07:11:41 -08:00
Googler d4357efea4 Adds exported_by function to cc_shared_library
This function is meant to be used for the tag containing exported_by.

RELNOTES:none
PiperOrigin-RevId: 298568236
Change-Id: Ia7b039d1764a3b79a3a0cc3f7f68a8eb17e6f0d5
2020-03-03 03:33:20 -08:00
Googler f38419606c Tests for changes in unknown commit
RELNOTES:none
PiperOrigin-RevId: 298567732
Change-Id: Ib3a14ee37a43a63fbfe2623f24c5dc710a941796
2020-03-03 03:28:56 -08:00
Googler be6ea43fc8 Allows libraries to be linked more than once.
Libraries are tagged with LINKABLE_MORE_THAN_ONCE can be linked into more than
one shared library and not give an error.

RELNOTES:none
PiperOrigin-RevId: 297352891
Change-Id: Id32b5c341bfd9d5906d67216773e82b0d8b63faf
2020-02-26 07:07:44 -08:00
Googler 52cd711ab7 Make sure cc_shared_library is guarded by flag
The --experimental_cc_shared_library used to block API methods
that were needed in the cc_shared_library implementation. However, these
methods have been made freely available to everyone so that people can start
migrating to the new API.

With that change, the cc_shared_library has become free to use unless we block
it with the method call added in this CL.

RELNOTES:none
PiperOrigin-RevId: 297127873
Change-Id: I103fe7724b9c4956a5bee8bed0f6d074a6e453f1
2020-02-25 08:58:44 -08:00
Googler 726dd81575 Remove attribute for visibility file.
The same command line can be obtained with the attributes
user_link_flags and additional_linker_inputs used together.

In the first design iterations of cc_shared_library it was decided to have the
visibility_file attribute so that a cc_shared_library could be used for many
different platforms smoothly.

For this to work the visibility file would have had to be platform neutral and
then Bazel would have had to write a visibility file specific for each
platform, e.g. the version script for Unix and the exports map for Windows.

However, in the last approved design it was decided not to have Bazel get in
the business of understanding symbols and automatically writing export maps.

With this approach, it then became necessary for people to use selects() in the
visibility_file attribute depending on the platform that the file was for.

Since we have added a new way to add files with the attribute
additional_linker_inputs and we need selects() anyway,
it doesn't make sense to keep the visibility_file attribute, the
same can be achieved with selects in the other two attributes mentioned.

In any case, if this can be made more ergonomic in the future, we can do so.
However, removing this attribute after flipping the experimental flag would be
an incompatible change.

PiperOrigin-RevId: 295925566
Change-Id: I52733e006f4b0f79f50380e89fc2eeae58dbad4d
2020-02-19 02:22:42 -08:00
Googler 0893766cef Allow unlimited number of additional linker inputs for cc_shared_library
RELNOTES:none
PiperOrigin-RevId: 295908805
Change-Id: I42a727d6ab0f4d342036df39a131d66ecd62734e
2020-02-19 00:10:00 -08:00
Googler 8f87c5e364 C++: Fixes order for cc_shared_library linked libs
Before dynamic lib dependencies of cc_shared_library were always linked at the
end. Now for creating the command line we respect the topological order that
would be given when getting the libs from the dependency graph created by the
cc_libraries.

RELNOTES:none
PiperOrigin-RevId: 295676824
Change-Id: I327a0e10920f18fed234dd5835e54cab75a0d428
2020-02-18 00:20:42 -08:00
Googler 810a11e772 C++: Allow libraries to be exported by any target
Any library should be exportable by any cc_shared_library target regardless of whether the cc_shared_library target is in the same package or a parent package as long as the library author gives permission.

The library author can now do this by writing tags=["exported_by=//foo,//baz"].

PiperOrigin-RevId: 295137965
Change-Id: I4acffd26981fedd6cb0c505e2691da0c70a7b6b0
2020-02-14 06:59:11 -08:00
Googler a2060ec7c9 C++: Remove linked_statically_by from cc_shared_library
RELNOTES:none
PiperOrigin-RevId: 295131987
Change-Id: I507106a7553da61f706b64c9232e4b7ea9a180d9
2020-02-14 06:11:35 -08:00
Googler 4de26b53a6 Remove need for exported_by or linked_statically_by
For now we will restrict allowed exports to the same package. At the same time
static_deps should be used to take into account what should be linked into a
shared library.

RELNOTES:none
PiperOrigin-RevId: 294668451
Change-Id: Ia087519106983bfa9a980e471d3102ab391a53eb
2020-02-12 08:01:50 -08:00
Googler cd0fa354f6 Remove linked_statically_by attribute for test
This is in preparation to renaming linked_statically_by to exported_by. The attribute linked_statically_by became redundant in a previous CL that added the static_deps attribute and made libraries in exports be linked statically automatically.

RELNOTES:none
PiperOrigin-RevId: 293355106
Change-Id: Iac987087e2f8e280f0fcaa2b7fcf61c55542825b
2020-02-05 06:24:04 -08:00
Googler 519989d3d5 Introduces static_deps attribute to cc_shared_library.
This removes the need for linked_statically_by, although both attributes work for now. The attribute linked_statically_by will disappear from cc_library and instead we will add exported_by which will allow library authors to retain the power of deciding who exports their library.

When a library is linked statically by more than one shared library and this library was only supposed to be linked once, i.e. it contains static initializers, then Bazel will give an error.

PiperOrigin-RevId: 293319906
Change-Id: I3713511e09feffb9429d38ac3ae868498ed4afe6
2020-02-05 01:25:55 -08:00