Page MenuHomePhabricator

[services] Clean up `install_cryptopp.sh` using ShellCheck
ClosedPublic

Authored by abosh on Aug 4 2022, 10:00 AM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Nov 26, 4:43 AM
Unknown Object (File)
Mon, Nov 25, 11:40 PM
Unknown Object (File)
Fri, Nov 8, 8:13 PM
Unknown Object (File)
Fri, Nov 8, 6:31 PM
Unknown Object (File)
Tue, Nov 5, 2:06 AM
Unknown Object (File)
Oct 5 2024, 6:40 PM
Unknown Object (File)
Oct 5 2024, 6:40 PM
Unknown Object (File)
Oct 5 2024, 6:40 PM

Details

Summary

Related Linear issue here. This is part of a set of diffs that will allow ShellCheck to be added to the CI. See inline comments for specific details of the ShellCheck error/warning output.

Test Plan

ShellCheck

This script is run in the tunnelbroker Docker build, so if that CI continues to build with no errors we can reasonably assume this script continues to work as expected.

Also, I ran git grep 'CXXFLAGS' and found no occurrences of it in the codebase.

Diff Detail

Repository
rCOMM Comm
Branch
master
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

abosh retitled this revision from [services] Clean up `install_cryptopp.sh` to [services] Clean up `install_cryptopp.sh` using ShellCheck.Aug 4 2022, 10:01 AM
abosh added a reviewer: karol.
abosh added inline comments.
services/tunnelbroker/docker/install_cryptopp.sh
9 ↗(On Diff #15319)
services/tunnelbroker/docker/install_cryptopp.sh
9 ↗(On Diff #15319)

This was most likely meant to use here

$ cat $(nix-build '<nixpkgs>' -A cryptopp.src)/GNUmakefile | grep CXXFLAGS | head -n 8
MACHINEX := $(shell $(CXX) $(CXXFLAGS) -dumpmachine 2>/dev/null)
SYSTEMX := $(shell $(CXX) $(CXXFLAGS) -dumpmachine 2>/dev/null)
ifeq ($(findstring -DCRYPTOPP_DISABLE_ASM,$(CXXFLAGS)),-DCRYPTOPP_DISABLE_ASM)
TCXXFLAGS := $(filter-out -D_FORTIFY_SOURCE=% -M -MM -Wall -Wextra -Werror% -Wunused -Wconversion -Wp%, $(CPPFLAGS) $(CXXFLAGS))
ifneq ($(strip $(TCXXFLAGS)),)
  $(info Using testing flags: $(TCXXFLAGS))
TCOMMAND = $(CXX) $(TCXXFLAGS) $(TEXTRA) $(ZOPT) $(TOPT) $(TPROG) -o $(TOUT)
# Base CXXFLAGS used if the user did not specify them
abosh added inline comments.
services/tunnelbroker/docker/install_cryptopp.sh
9 ↗(On Diff #15319)

Thank you! That makes sense to me, will update. Also, next time you provide feedback can you select Request Changes so it pops up in my queue/updates for other reviewers?

atul requested changes to this revision.Aug 4 2022, 11:17 AM

CXXFLAGS is picked up by make

CXXFLAGS
Extra flags to give to the C++ compiler.

(https://www.gnu.org/software/make/manual/make.html#index-CFLAGS)


Jon's suggestion to define CXXFLAGS for the make command makes sense

This revision now requires changes to proceed.Aug 4 2022, 11:17 AM
abosh marked an inline comment as done.

Move CXXFLAGS into make command, per @jon's feedback.

Also, next time you provide feedback can you select Request Changes so it pops up in my queue/updates for other reviewers?

Keep forgetting this is default behavior for github but not phabricator

LGTM, assuming tunnelbroker CI passes

In D4738#136553, @jon wrote:

Also, next time you provide feedback can you select Request Changes so it pops up in my queue/updates for other reviewers?

Keep forgetting this is default behavior for github but not phabricator

Off topic, but I wonder if you could set up a Herald view to emulate the GitHub behavior

atul requested changes to this revision.Aug 4 2022, 11:35 AM

Minor note, but I'm used to setting the ENV variables before the command... from man bash:

The environment for any simple command or  function  may  be  augmented
temporarily  by  prefixing  it with parameter assignments, as described
above in PARAMETERS.  These assignment statements affect only the envi-
ronment seen by that command.

which I think would be something like

CXXFLAGS="-DNDEBUG -g2 -O3 -std=c++11" make

Are we sure these flags aren't also relevant for the make libcryptopp.pc and make install commands?

Maybe we should export CXXFLAGS or suppress the shellcheck warning?

This revision now requires changes to proceed.Aug 4 2022, 11:35 AM

Maybe we should export CXXFLAGS or suppress the shellcheck warning?

IIRC make doesn't consume from ENV unless you use the ?= or := operator

https://stackoverflow.com/questions/24263291/define-a-makefile-variable-using-a-env-variable-or-a-default-value

I cat'd some of the file to show that it doesn't do this, instead it just blindly uses it if declared as a positional flag.

In D4738#136566, @jon wrote:

Maybe we should export CXXFLAGS or suppress the shellcheck warning?

IIRC make doesn't consume from ENV unless you use the ?= or := operator

https://stackoverflow.com/questions/24263291/define-a-makefile-variable-using-a-env-variable-or-a-default-value

I cat'd some of the file to show that it doesn't do this, instead it just blindly uses it if declared as a positional flag.

Ah my mistake, thanks for clarifying and linking to that. Should we still append that to all of the make commands?

This revision is now accepted and ready to land.Aug 4 2022, 11:45 AM

Should we still append that to all of the make commands?

Most good makefiles will set it to something reasonable for the install targets, as you likely want a release version. I would say "defer to upstream unless it's detrimental"