Skip to content

Commit

Permalink
Redirect grep stderr to /dev/null. (#723)
Browse files Browse the repository at this point in the history
Details:
- In common.mk, added a redirection of stderr to /dev/null for the grep
  command being used to gather a list of header files #included from
  bli_cntx_ref.c. The redirection is desirable because as of grep 3.8,
  regular expressions with "stray" backslashes trigger warnings [1].
  But removing the backslash seems to break the BLIS build system when
  using pre-3.8 versions of grep, so this seems to be easiest way to
  satisfy the BLIS build system for both pre- and post-3.8 grep
  environments.

  [1] https://lists.gnu.org/archive/html/info-gnu/2022-09/msg00001.html
  • Loading branch information
fgvanzee authored Feb 10, 2023
1 parent e3d352f commit b1d3fc7
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,7 @@ GREP := grep
EGREP := grep -E
XARGS := xargs
INSTALL := install -c
DEVNULL := /dev/null

# Script for creating a monolithic header file.
#FLATTEN_H := $(DIST_PATH)/build/flatten-headers.sh
Expand Down Expand Up @@ -1181,7 +1182,18 @@ CBLAS_H_FLAT := $(BASE_INC_PATH)/$(CBLAS_H)
# files will be needed when compiling bli_cntx_ref.c with the monolithic header.
ifeq ($(strip $(SHARE_PATH)),.)
REF_KER_SRC := $(DIST_PATH)/$(REFKERN_DIR)/bli_cntx_ref.c
REF_KER_HEADERS := $(shell $(GREP) "\#include" $(REF_KER_SRC) | sed -e "s/\#include [\"<]\([a-zA-Z0-9\_\.\/\-]*\)[\">].*/\1/g" | $(GREP) -v $(BLIS_H))
#
# NOTE: A redirect to /dev/null has been added to the grep command below because
# as of version 3.8, grep outputs warnings when encountering stray backslashes
# in regular expressions [1]. Versions older than 3.8 not only do not complain,
# but actually seem to *require* the backslash, perhaps because of the way we
# are invoking grep via GNU make's shell command. WHEN DEBUGGING ANYTHING
# INVOLVING THE MAKE VARIABLE BELOW, PLEASE CONSIDER TEMPORARILY REMOVING THE
# REDIRECT TO /dev/null SO THAT YOU SEE ANY MESSAGES SENT TO STANDARD ERROR.
#
# [1] https://lists.gnu.org/archive/html/info-gnu/2022-09/msg00001.html
#
REF_KER_HEADERS := $(shell $(GREP) "\#include" $(REF_KER_SRC) 2> $(DEVNULL) | sed -e "s/\#include [\"<]\([a-zA-Z0-9\_\.\/\-]*\)[\">].*/\1/g" | $(GREP) -v $(BLIS_H))
endif

# Match each header found above with the path to that header, and then strip
Expand Down

0 comments on commit b1d3fc7

Please sign in to comment.