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

2.1 only: add tests/scripts/doxygen.sh and fix make apidoc #2011

Merged

Conversation

gilles-peskine-arm
Copy link
Contributor

@gilles-peskine-arm gilles-peskine-arm commented Sep 10, 2018

Add tests/scripts/doxygen.sh like in 2.7 and development. This lets us keep our CI scripts uniform. Fix #2010.

Fix the doxygen configuration to work with modern Doxygen versions without warnings.

make apidoc now generates the documentation for the current configuration. Run scripts/apidoc_full.sh to generate the full documentation. This aligns the behavior with Mbed TLS 2.2+ and permits parallel builds (#390 #391).

This is a backport of a branch that was merged in 2.2.2 at 9a3ee57 without a Github pull request.

Additionally, there is a backport of the commit “Look for documentation only in specific directories” from #2031, which was not included in #2033 because it interacts with other changes in this PR.

We also debated backporting #1284 for uniformity with the other maintained branches but this is a change in behavior and not a bug fix in any way.

mpg and others added 9 commits September 10, 2018 12:11
Doxygen 1.8.10 warns that those tags are obsolete. Since we're not generating
XML anyway, it seems harmless to remove them even for earlier versions.
Apparently travis has an old version of doxygen that doesn't know all tags in
our config. That's not something we care about, we only want to know about
warnings in our doxygen content
Previous change to include excluded the content in doxygen/input
This partially reverts 1989caf (only the changes to Makefile and
CMakeLists, the addition to scripts/config.pl is kept).

Modifying config.h in the apidoc target creates a race condition with

    make -j4 all apidoc

where some parts of the library, tests or programs could be built with the
wrong config.h, resulting in all kinds of (semi-random) errors. Recent
versions of CMake mitigate this by adding a .NOTPARALLEL target to the
generated Makefile, but people would still get errors with older CMake
versions that are still in use (eg in RHEL 5), and with plain make.

An additional issue is that, by failing to use cp -p, the apidoc target was
updating the timestamp on config.h, which seems to cause further build issues.

Let's get back to the previous, safe, situation. The improved apidoc building
will be resurrected in a script in the next commit.

fixes Mbed-TLS#390
fixes Mbed-TLS#391
This re-introduces the apidoc with full config.h, but hopefully with the race
conditions and other issues that the previous implementation had.

Adapt doxygen test script to use that new script, and also check for errors
in addition to warnings while at it.
@gilles-peskine-arm gilles-peskine-arm added mbed TLS team needs-review Every commit must be reviewed by at least two team members, component-platform Portability layer and build scripts labels Sep 10, 2018
@Patater
Copy link
Contributor

Patater commented Sep 10, 2018

retest

Copy link
Contributor

@andresag01 andresag01 left a comment

Choose a reason for hiding this comment

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

@gilles-peskine-arm: Thanks for the PR, I think the changes look good.

Before approving I have a quick question: Why are there some differences in the backported changes between the 2.1 branch and development? For example, I think the 2.1 branch assumes that doxygen is run from the project root while development assumes that it is run from the doxygen directory. I do not know why this is the case, but perhaps its ideal to keep them in sync?

@gilles-peskine-arm
Copy link
Contributor Author

@andresag01 That's a good question. The change in directory was made in #1284. I'd initially preferred to keep the changes minimal and only backport what had been done for 2.2. However I hadn't paid attention that #1284 is already present in 2.7 (it was merged just before the 2.7 release), so 2.1 remains the odd man out. Backports should minimize behavior changes, but this patch already changes the behavior of make apidoc (full config → current config), and the Doxyfile gave warnings with modern Doxygen versions. Arguments against backporting: it's a bigger behavior change, and the Doxyfile warnings could be ignored. So should #1284 be backported as well? @andresag01 @mpg

@andresag01
Copy link
Contributor

@gilles-peskine-arm: I agree that generally we should aim to maintain behaviour in the LTS. However, the change in #1284 seems minor as it is just regarding the place where the docs are generated. It would be a different discussion if we were talking about a change in the API or ABI of the code. I am not sure about the warnings. Are they also being ignored in the development and 2.7 branches? If this is the case, then I do not think we should be too concerned about that. In summary, I would prefer it to be backported as well.

@mpg
Copy link
Contributor

mpg commented Sep 12, 2018

@gilles-peskine-arm @andresag01 I'm sorry, can you clarify what the behaviour changes are currently, and what additional behaviour change would be introduced by backporting #1284 too? By "the place where the docs are generated", do you mean (a) what the working directory needs to be when invoking the script, or (b) the final place where the docs are going to be found after generation, or (c) something else?

@gilles-peskine-arm
Copy link
Contributor Author

gilles-peskine-arm commented Sep 12, 2018

The following changes were made in 2.2 (via a PR-less branch), and this PR backports them:

  • Before: modern versions of Doxygen emitted a warning about unknown settings in the doxyfile. After: no warnings. This change does not affect the Doxygen output.
  • Before: make apidoc generates the documentation for the full configuration. After: make apidoc generates the documentation for the current configuration.
  • Before: make apidoc lib fails in parallel builds because it temporarily moves config.h. After: make -j apidoc lib works.
  • Before: there is no tests/scripts/doxygen.sh so we can't indiscriminately call it in CI jobs. After: tests/scripts/doxygen.sh works so we can call it from CI jobs.

The following change was made in 2.7 (via #1284) and I'm considering backporting it:

  • Before: if you run Doxygen manually with the Doxyfile (as opposed to calling make apidoc), you have to run it from the top-level directory. After: if you run Doxygen manually, you have to run it from the doxygen subdirectory. (So @mpg it's (a) only.)

@mpg
Copy link
Contributor

mpg commented Sep 12, 2018

@gilles-peskine-arm Thanks for that very clear summary!

The changes that this PR already backports are obviously fine and desirable. In my opinion, the change introduced by #1284 is also acceptable for the 2.1 branch, as the behaviour when invoking make apidoc is unchanged. (It's debatable whether running doxygen manually is part of our guaranteed-stable API, but in practice even in the unlikely case someone was doing it and this change is a problem for them, there are easy fixes.) I'd argue that since this change is acceptable, it's also desirable, in order to get closer alignment between branches.

@mpg
Copy link
Contributor

mpg commented Sep 12, 2018

I think Andres and me both think #1284 should be backported, and you don't seem to disagree, so I'm adding "needs work" and will review once that additional part has been backported.

mpg
mpg previously approved these changes Sep 13, 2018
Copy link
Contributor

@mpg mpg left a comment

Choose a reason for hiding this comment

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

This looks like a proper backport of the set of doxygen-related things we want to backport.

andresag01
andresag01 previously approved these changes Sep 20, 2018
@gilles-peskine-arm gilles-peskine-arm removed the needs-review Every commit must be reviewed by at least two team members, label Sep 20, 2018
@simonbutcher
Copy link
Contributor

I'm really open to discussion or debate, but I'm really not sold on changing the targets in the Makefile on a maintained branch. I see no strong or compelling reason to do it.

@mpg
Copy link
Contributor

mpg commented Oct 2, 2018

The maintained branches are supposed to be bug-fixes only, and test enhancements. This exceeds that.

I agree about reverting the backport of #1284 for that reason, but I think the other behaviour change was necessary to fix a bug, hence its inclusion in a maintained branch was justified. The bug is that make -j all apidoc will fail (with an error in the best case, or silently producing inconsistent results), and I'm not sure there is a simple way to fix that without also changing the behaviour of the target.

I think it was pjbakker's intention that the documentation be generated this way, and I think we should leave it as is.

I checked the history and I don't think the behaviour was really Paul's intention. That change was introduced in 2.2.1 and backported in 2.1.4, so we would merely be reverting to what the behaviour was from 2.1.0 to 2.1.3. For some reason we backported the faulty commit but forgot to backport its reversal (that is, until this PR).

I think that strengthens my previous point: not only is this fixing a bug, it's fixing a bug that we introduced in a maintained branch (while trying to fix another one, but going the wrong way about it).

(By the way, if we followed your advice back then and tried harder to avoid changing behaviour in maintained branches, we probably would have been forced to fix the warnings another way and would have avoided introducing this bug in the first place. So I think your care is justified - I just happen to disagree about this particular instance.)

@gilles-peskine-arm
Copy link
Contributor Author

The current version of the PR as I write (which I'm archiving to https://github.com/gilles-peskine-arm/mbedtls/tree/doxygen-fixes-2.1-make_apidoc_is_not_full) makes two changes which are at the border between enhancements and bugs. They don't reconcile the behavior between the implementation and the documentation because we didn't document the intended behavior — but by the same token they don't break documented behavior.

  • We didn't explicitly promise that parallel builds work. But it's a natural expectation, and more and more so over time.
  • We didn't explicitly promise that make apidoc generates the documentation according to the current configuration as opposed to the full documentation of every possible feature. But it's a natural expectation that the sole build target that generates documentation builds the documentation that corresponds to the code, and not the documentation for a different configuration.

As Manuel notes, both expectations were met until 2.1.3, which is an argument for fulfilling them again. On the other hand, they've been broken on the 2.1 branch for 2½ years and nobody has complained that I could find, which is an argument for leaving things as they are.

I have a preference for fixing the arguably-bugs, but it isn't a strong preference. I have a strong preference for getting tests/scripts/doxygen.sh in one way or another.

@gilles-peskine-arm
Copy link
Contributor Author

A branch that preserves the 2.1.4+ behavior (make apidoc generates the full documentation) is at https://github.com/gilles-peskine-arm/mbedtls/tree/doxygen-fixes-2.1-no_target_change

Generate the documentation from include and doxygen/input only. Don't
get snared by files containing Doxygen comments that lie in other
directories such as tests, yotta, crypto/include, ...

The only difference this makes in a fresh checkout is that the
documentation no longer lists target_config.h. This file is from
yotta, does not contain any Doxygen comment, and its inclusion in the
rendered documentation was clearly an oversight.
@gilles-peskine-arm gilles-peskine-arm added the needs-review Every commit must be reviewed by at least two team members, label Oct 2, 2018
@simonbutcher
Copy link
Contributor

Ok, I can accept @mpg's point. We're just reverting it back to the way it was done in mbedtls-2.1.3. There's a danger of over debating this, and what is effectively a small change to something that doesn't change the library itself. I was trying to stick to a point of principle here, because since 2.1.3, which was our first LTS and maintained branch, we've learnt a lot about user's expectations on maintaining the interfaces, and I don't think we'd make the same decisions again - and maintaining consistency of build targets and supported toolchains is important on such branches.

Therefore I accept the change.

@gilles-peskine-arm gilles-peskine-arm added approved for design and removed needs-design-approval needs-review Every commit must be reviewed by at least two team members, labels Oct 2, 2018
@gilles-peskine-arm
Copy link
Contributor Author

Since you've both approved the PR, I take it this is approved for design. The CI job that was breaking has successfully run tests/scripts/doxygen.sh (https://jenkins-internal.mbed.com/job/mbedtls-restricted-pr/412/). So this is presumably ready for merge.

@simonbutcher
Copy link
Contributor

retest

@simonbutcher simonbutcher added the needs-ci Needs to pass CI tests label Oct 2, 2018
@simonbutcher
Copy link
Contributor

retest

1 similar comment
@simonbutcher
Copy link
Contributor

retest

@simonbutcher
Copy link
Contributor

CI passes! Yay! Labelling as 'Ready to Merge'.

@simonbutcher simonbutcher added approved Design and code approved - may be waiting for CI or backports and removed needs-ci Needs to pass CI tests labels Oct 11, 2018
@simonbutcher simonbutcher merged commit a2710dc into Mbed-TLS:mbedtls-2.1 Oct 25, 2018
simonbutcher added a commit that referenced this pull request Oct 25, 2018
The Changelog merged the PR #2011 entry under the wrong version. This corrects
that merge error, and also clarifies the entry.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Design and code approved - may be waiting for CI or backports bug component-platform Portability layer and build scripts enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants