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

Autotools examples #754

Merged
merged 4 commits into from
Nov 19, 2021
Merged

Autotools examples #754

merged 4 commits into from
Nov 19, 2021

Conversation

jsharpe
Copy link
Member

@jsharpe jsharpe commented Aug 5, 2021

Add targets to build autotools with the aim of eventually moving these to use the built_tools framework and put into a toolchain that the configure_make rule can use to ensure hermetic use of autotools during the build.

Fixes an issue with putting the bin directory from built tools onto the path when using tools_deps

@jsharpe jsharpe force-pushed the autotools_build branch 2 times, most recently from b9bd840 to 10befa9 Compare August 6, 2021 20:44
@jsharpe jsharpe requested a review from UebelAndre August 6, 2021 21:09
@jsharpe jsharpe marked this pull request as ready for review August 6, 2021 21:09
@jsharpe
Copy link
Member Author

jsharpe commented Aug 6, 2021

This is green now but with the caveat that only m4 actually produces a working tool. automake isn't being built as autoconf generates scripts with hardcoded paths that match the install prefix and hence contains sandbox paths. Some can be worked around using environment variables but not all config unfortunately.

Anyone have any smart ideas on how to produce a reproducible and relocatable autoconf install?

@UebelAndre
Copy link
Collaborator

automake isn't being built as autoconf generates scripts with hardcoded paths that match the install prefix and hence contains sandbox paths.

would something like replace_in_files help?
https://github.com/bazelbuild/rules_foreign_cc/blob/f01fd353ee2adcd55aab899c12fa2733223228a1/foreign_cc/private/framework/toolchains/linux_commands.bzl#L62-L83

What is the specific issue with the hard coded paths?

@jsharpe
Copy link
Member Author

jsharpe commented Aug 16, 2021

automake isn't being built as autoconf generates scripts with hardcoded paths that match the install prefix and hence contains sandbox paths.

would something like replace_in_files help?

https://github.com/bazelbuild/rules_foreign_cc/blob/f01fd353ee2adcd55aab899c12fa2733223228a1/foreign_cc/private/framework/toolchains/linux_commands.bzl#L62-L83

What is the specific issue with the hard coded paths?

It's the generated autom4te script and its config files; they include the path specified as the install prefix in them and so this results in files not being found. Some can be worked around by setting environment variables to override such paths but this doesn't work for the config files where absolute paths are required (although I've not looked to see if it would expand an environment variable at time of use)

@djmarcin
Copy link
Contributor

I actually just had this exact problem with autoconf — but my “solution” was to tag the targets as ‘no-sandbox’ and ‘no-cache’ so that the embedded paths would be the persistent execroot path and not an ephemeral sandbox path. More of a workaround than a solution, really. It requires #765 because otherwise rules_foreign_cc throws away these tags.

@djmarcin
Copy link
Contributor

djmarcin commented Sep 7, 2021

Curious if @jsharpe has had any further ideas here. I've been thinking about this a lot because we are trying to enable remote exec for our build and the no-sandbox solution doesn't work there. I've also tried a repository rule that builds autotools, which also only works locally -- once a task on a remote machine tries to use autoconf it fails because it tries to read the execroot path from my local machine, which obviously doesn't exist remotely.

It's unsatisfying, but without significant patches for autotools to be arbitrarily relocatable, I don't see how it can be successfully vendored inside bazel. I think I'm going to solve our need by just manually installing the versions we need into well known locations on all our build machines and referencing it directly. I think there are a few other tools in this non-relocatable bucket that need the same treatment (and by extension, can't effectively be built with rules_foreign_cc)

@jsharpe jsharpe force-pushed the autotools_build branch 4 times, most recently from b7cf86f to bf51e21 Compare November 18, 2021 00:16
@jsharpe jsharpe linked an issue Nov 18, 2021 that may be closed by this pull request
@jsharpe
Copy link
Member Author

jsharpe commented Nov 18, 2021

@UebelAndre PTAL.
I've not worked out a way to make the autoconf build relocatable and so automake won't build either. I've not turned on the build for either of these for now but this at least fixes the bison build by building m4 from source (although it doesn't work on RBE due to the timestamping issues 😢 ).
I could remove the autoconf and automake build files from this PR if you'd prefer not to add the broken build files?

Copy link
Collaborator

@UebelAndre UebelAndre left a comment

Choose a reason for hiding this comment

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

I think this is mostly fine since it's just adding examples. Is this a stepping stone to building autotools for the foreign_cc toolchains? I'd otherwise say maybe there wouldn't be much value in the examples since they're gonna be ripped out for something better maintained.

But I leave the decision up to you. One question but otherwise looks good!

foreign_cc/private/framework.bzl Outdated Show resolved Hide resolved
@jsharpe
Copy link
Member Author

jsharpe commented Nov 18, 2021

I think this is mostly fine since it's just adding examples. Is this a stepping stone to building autotools for the foreign_cc toolchains? I'd otherwise say maybe there wouldn't be much value in the examples since they're gonna be ripped out for something better maintained.

But I leave the decision up to you. One question but otherwise looks good!

Yes; my idea was to get them building in examples, then add toolchain definitions for each of the components then migrate the examples into built_tools to create a hermetic toolchain setup for autotools et al.

@jsharpe
Copy link
Member Author

jsharpe commented Nov 18, 2021

Note that native rules for building some of these tools exist e.g. m4: https://github.com/hdl/bazel_rules_hdl/tree/main/dependency_support/org_gnu_m4

@UebelAndre
Copy link
Collaborator

By the way: Buildifier needs to be run 😅

@jsharpe jsharpe enabled auto-merge (squash) November 19, 2021 00:40
@jsharpe jsharpe merged commit 7baefc1 into bazel-contrib:main Nov 19, 2021
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.

Fix Bison example tests
3 participants