[LU-9934] support gcc7 Created: 31/Aug/17  Updated: 13/Sep/18  Resolved: 06/Mar/18

Status: Resolved
Project: Lustre
Component/s: None
Affects Version/s: Lustre 2.11.0
Fix Version/s: Lustre 2.11.0

Type: Improvement Priority: Minor
Reporter: Alex Zhuravlev Assignee: Alex Zhuravlev
Resolution: Fixed Votes: 0
Labels: None
Environment:

gcc7


Issue Links:
Related
is related to LU-9833 New gcc compiler generates a lot of f... Resolved
is related to LU-8587 gcc6 compatibility Closed
Rank (Obsolete): 9223372036854775807

 Description   

Lustre doesn't build with newer gcc7 due to many different warnings. some are easier to fix in the code. another are rather false (see an example below) and easier to supress.

util/parser.c:575:25: error: ‘%2d’ directive output may be truncated writing between 2 and 10 bytes into a region of size 4 [-Werror=format-truncation=]



 Comments   
Comment by Gerrit Updater [ 31/Aug/17 ]

Alex Zhuravlev (alexey.zhuravlev@intel.com) uploaded a new patch: https://review.whamcloud.com/28810
Subject: LU-9934 build: support for gcc7
Project: fs/lustre-release
Branch: master
Current Patch Set: 1
Commit: 5200a2f474fe049f3cf6176842e92aae2a6c5c64

Comment by Gerrit Updater [ 05/Dec/17 ]

James Simmons (uja.ornl@yahoo.com) uploaded a new patch: https://review.whamcloud.com/30376
Subject: LU-9934 build: address issues raised by gcc7
Project: fs/lustre-release
Branch: master
Current Patch Set: 1
Commit: 6bb8778b2660b83f9ef83af12c5f0536f2b164a9

Comment by Alex Zhuravlev [ 12/Dec/17 ]

with the latest patch:

/home/alexey/head2/libcfs/libcfs/workitem.c: In function ‘cfs_wi_sched_create’:
/home/alexey/head2/libcfs/libcfs/workitem.c:384:37: error: ‘%02d’ directive output may be truncated writing between 2 and 11 bytes into a region of size between 0 and 15 [-Werror=format-truncation=]
snprintf(name, sizeof(name), "%s_%02d_%02d",
^~~~
/home/alexey/head2/libcfs/libcfs/workitem.c:384:4: note: ‘snprintf’ output between 7 and 39 bytes into a destination of size 16
snprintf(name, sizeof(name), "%s_%02d_%02d",
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sched->ws_name, sched->ws_cpt,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sched->ws_nthreads);
~~~~~~~~~~~~~~~~~~~
/home/alexey/head2/libcfs/libcfs/workitem.c:388:37: error: ‘%02d’ directive output may be truncated writing between 2 and 10 bytes into a region of size between 0 and 15 [-Werror=format-truncation=]
snprintf(name, sizeof(name), "%s_%02d",
^~~~
/home/alexey/head2/libcfs/libcfs/workitem.c:388:33: note: directive argument in the range [0, 1073741823]
snprintf(name, sizeof(name), "%s_%02d",
^~~~~~~~~
/home/alexey/head2/libcfs/libcfs/workitem.c:388:4: note: ‘snprintf’ output between 4 and 27 bytes into a destination of size 16
snprintf(name, sizeof(name), "%s_%02d",
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sched->ws_name, sched->ws_nthreads);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[6]: *** [scripts/Makefile.build:341: /home/alexey/head2/libcfs/libcfs/workitem.o] Error 1
make[5]: *** [scripts/Makefile.build:488: /home/alexey/head2/libcfs/libcfs] Error 2
make[4]: *** [scripts/Makefile.build:488: /home/alexey/head2/libcfs] Error 2
make[4]: *** Waiting for unfinished jobs....
/home/alexey/head2/lustre/osp/lwp_dev.c: In function ‘lwp_notify_users’:
/home/alexey/head2/lustre/osp/lwp_dev.c:453:46: error: ‘%s’ directive output may be truncated writing up to 127 bytes into a region of size 53 [-Werror=format-truncation=]
snprintf(name, MTI_NAME_MAXLEN, "lwp_notify_%s",
^~
/home/alexey/head2/lustre/osp/lwp_dev.c:453:2: note: ‘snprintf’ output between 12 and 139 bytes into a destination of size 64
snprintf(name, MTI_NAME_MAXLEN, "lwp_notify_%s",
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
exp->exp_obd->obd_name);
~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[6]: *** [scripts/Makefile.build:341: /home/alexey/head2/lustre/osp/lwp_dev.o] Error 1
make[5]: *** [scripts/Makefile.build:488: /home/alexey/head2/lustre/osp] Error 2
make[5]: *** Waiting for unfinished jobs....
/home/alexey/head2/lustre/mdc/mdc_changelog.c: In function ‘mdc_changelog_cdev_init’:
/home/alexey/head2/lustre/mdc/mdc_changelog.c:606:38: error: ‘%s’ directive output may be truncated writing up to 127 bytes into a region of size 22 [-Werror=format-truncation=]
snprintf(name, name_len, "changelog-%s", obd->obd_name);
^~
/home/alexey/head2/lustre/mdc/mdc_changelog.c:606:2: note: ‘snprintf’ output between 11 and 138 bytes into a destination of size 32
snprintf(name, name_len, "changelog-%s", obd->obd_name);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[6]: *** [scripts/Makefile.build:341: /home/alexey/head2/lustre/mdc/mdc_changelog.o] Error 1
make[5]: *** [scripts/Makefile.build:488: /home/alexey/head2/lustre/mdc] Error 2
/home/alexey/head2/lustre/mdd/mdd_orphans.c: In function ‘mdd_orphan_cleanup’:
/home/alexey/head2/lustre/mdd/mdd_orphans.c:597:48: error: ‘%s’ directive output may be truncated writing up to 127 bytes into a region of size 51 [-Werror=format-truncation=]
snprintf(name, MTI_NAME_MAXLEN, "orph_cleanup_%s",
^~
/home/alexey/head2/lustre/mdd/mdd_orphans.c:597:2: note: ‘snprintf’ output between 14 and 141 bytes into a destination of size 64
snprintf(name, MTI_NAME_MAXLEN, "orph_cleanup_%s",
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mdd2obd_dev(d)->obd_name);
~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[6]: *** [scripts/Makefile.build:341: /home/alexey/head2/lustre/mdd/mdd_orphans.o] Error 1
make[5]: *** [scripts/Makefile.build:488: /home/alexey/head2/lustre/mdd] Error 2
/home/alexey/head2/lustre/ptlrpc/nrs_orr.c: In function ‘nrs_orr_start’:
/home/alexey/head2/lustre/ptlrpc/nrs_orr.c:373:42: error: ‘%s’ directive output may be truncated writing up to 15 bytes into a region of size 12 [-Werror=format-truncation=]
snprintf(name, NRS_ORR_OBJ_NAME_MAX, "%s%s%s%d",
^~
/home/alexey/head2/lustre/ptlrpc/nrs_orr.c:373:2: note: ‘snprintf’ output between 10 and 36 bytes into a destination of size 16
snprintf(name, NRS_ORR_OBJ_NAME_MAX, "%s%s%s%d",
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"nrs_", policy->pol_desc->pd_name,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
policy->pol_nrs->nrs_queue_type == PTLRPC_NRS_QUEUE_REG ?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"reg" : "hp", nrs_pol2cptid(policy));
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[6]: *** [scripts/Makefile.build:341: /home/alexey/head2/lustre/ptlrpc/nrs_orr.o] Error 1
make[6]: *** Waiting for unfinished jobs....
/home/alexey/head2/lustre/quota/qsd_reint.c: In function ‘qsd_start_reint_thread’:
/home/alexey/head2/lustre/quota/qsd_reint.c:671:48: error: ‘%s’ directive output may be truncated writing up to 127 bytes into a region of size between 42 and 52 [-Werror=format-truncation=]
snprintf(name, MTI_NAME_MAXLEN, "qsd_reint_%d.%s",
^~
/home/alexey/head2/lustre/quota/qsd_reint.c:671:2: note: ‘snprintf’ output between 13 and 150 bytes into a destination of size 64
snprintf(name, MTI_NAME_MAXLEN, "qsd_reint_%d.%s",
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
qqi->qqi_qtype, qsd->qsd_svname);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[6]: *** [scripts/Makefile.build:341: /home/alexey/head2/lustre/quota/qsd_reint.o] Error 1
make[5]: *** [scripts/Makefile.build:488: /home/alexey/head2/lustre/quota] Error 2
/home/alexey/head2/lustre/ptlrpc/ptlrpcd.c: In function ‘ptlrpcd_ctl_init’:
/home/alexey/head2/lustre/ptlrpc/ptlrpcd.c:540:19: error: ‘%02d’ directive output may be truncated writing between 2 and 10 bytes into a region of size between 0 and 5 [-Werror=format-truncation=]
"ptlrpcd_%02d_%02d", cpt, index);
^~~~
/home/alexey/head2/lustre/ptlrpc/ptlrpcd.c:540:5: note: directive argument in the range [-1, 2147483647]
"ptlrpcd_%02d_%02d", cpt, index);
^~~~~~~~~~~~~~~~~~~
/home/alexey/head2/lustre/ptlrpc/ptlrpcd.c:539:3: note: ‘snprintf’ output between 14 and 31 bytes into a destination of size 16
snprintf(pc->pc_name, sizeof(pc->pc_name),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"ptlrpcd_%02d_%02d", cpt, index);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[6]: *** [scripts/Makefile.build:341: /home/alexey/head2/lustre/ptlrpc/ptlrpcd.o] Error 1
make[5]: *** [scripts/Makefile.build:488: /home/alexey/head2/lustre/ptlrpc] Error 2
/home/alexey/head2/lustre/mgs/mgs_handler.c: In function ‘mgs_target_reg’:
/home/alexey/head2/lustre/mgs/mgs_handler.c:405:52: error: ‘%s’ directive output may be truncated writing up to 63 bytes into a region of size 19 [-Werror=format-truncation=]
snprintf(barrier_name, sizeof(barrier_name) - 1, "%s-%s",
^~
/home/alexey/head2/lustre/mgs/mgs_handler.c:405:2: note: ‘snprintf’ output between 9 and 72 bytes into a destination of size 19
snprintf(barrier_name, sizeof(barrier_name) - 1, "%s-%s",
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mti->mti_fsname, BARRIER_FILENAME);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[6]: *** [scripts/Makefile.build:341: /home/alexey/head2/lustre/mgs/mgs_handler.o] Error 1
make[6]: *** Waiting for unfinished jobs....
/home/alexey/head2/lustre/mgs/mgs_llog.c: In function ‘mgs_write_log_target’:
/home/alexey/head2/lustre/mgs/mgs_llog.c:2499:27: error: ‘%s’ directive output may be truncated writing up to 63 bytes into a region of size 40 [-Werror=format-truncation=]
"%s_UUID", mti->mti_svname);
^~
/home/alexey/head2/lustre/mgs/mgs_llog.c:2498:17: note: ‘snprintf’ output between 6 and 69 bytes into a destination of size 40
snprintf(mti->mti_uuid, sizeof(mti->mti_uuid),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"%s_UUID", mti->mti_svname);
~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/alexey/head2/lustre/mgs/mgs_llog.c:2768:27: error: ‘%s’ directive output may be truncated writing up to 63 bytes into a region of size 40 [-Werror=format-truncation=]
"%s_UUID", mti->mti_svname);
^~
/home/alexey/head2/lustre/mgs/mgs_llog.c:2767:17: note: ‘snprintf’ output between 6 and 69 bytes into a destination of size 40
snprintf(mti->mti_uuid, sizeof(mti->mti_uuid),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"%s_UUID", mti->mti_svname);
~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/alexey/head2/lustre/mgs/mgs_llog.c:2813:44: error: ‘sprintf’ may write a terminating nul past the end of the destination [-Werror=format-overflow=]
sprintf(mdt_index, "-MDT%04x", i);
^~~~~~~~~~
/home/alexey/head2/lustre/mgs/mgs_llog.c:2813:25: note: ‘sprintf’ output between 9 and 10 bytes into a destination of size 9
sprintf(mdt_index, "-MDT%04x", i);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Comment by Gerrit Updater [ 25/Jan/18 ]

Oleg Drokin (oleg.drokin@intel.com) merged in patch https://review.whamcloud.com/30376/
Subject: LU-9934 build: address issues raised by gcc7
Project: fs/lustre-release
Branch: master
Current Patch Set:
Commit: 61743b88672687f789f9c609c85a351e1595118b

Comment by Peter Jones [ 25/Jan/18 ]

Alex

Does your patch need to land too or was James's sufficient?

Peter

Comment by Alex Zhuravlev [ 25/Jan/18 ]

going to check in my setup today.

Comment by Alex Zhuravlev [ 25/Jan/18 ]

I'm still getting those errors with gcc7.. will it be another patch?

Comment by Alex Zhuravlev [ 25/Jan/18 ]

what's wrong with -Wno-format-truncation ?

Comment by Alex Zhuravlev [ 25/Jan/18 ]

I've updated my patch (now much smaller) to be able to build with gcc7
notice #include <sys/sysmacros.h>
w/o that I'm getting this:

libmount_utils_ldiskfs.c: In function ‘tune_block_dev’:
libmount_utils_ldiskfs.c:1234:13: error: In the GNU C Library, "major" is defined
by <sys/sysmacros.h>. For historical compatibility, it is
currently defined by <sys/types.h> as well, but we plan to
remove this soon. To use "major", include <sys/sysmacros.h>
directly. If you did not intend to use a system-defined macro
"major", you should undefine it after including <sys/types.h>. [-Werror]
if (major(st.st_rdev) == LOOP_MAJOR)
^~~~~~~~~~~~~~~~~~~~~~~~~

Comment by James A Simmons [ 26/Jan/18 ]

Thanks. I also see another patch just landed that break Ubuntu17 builds again  Its in lnetconfig library.

Comment by Gerrit Updater [ 06/Mar/18 ]

Oleg Drokin (oleg.drokin@intel.com) merged in patch https://review.whamcloud.com/28810/
Subject: LU-9934 build: support for gcc7
Project: fs/lustre-release
Branch: master
Current Patch Set:
Commit: 4b67e5a8150309f4bbeb43a9095f12243be6dcfa

Comment by Peter Jones [ 06/Mar/18 ]

Landed for 2.11

Comment by Gerrit Updater [ 27/Mar/18 ]

Li Dongyang (dongyangli@ddn.com) uploaded a new patch: https://review.whamcloud.com/31791
Subject: LU-9934 build: fix gcc7 complains in lprocfs_status_server.c
Project: fs/lustre-release
Branch: master
Current Patch Set: 1
Commit: ca080cc5877ed4bb521c03466f92324760d5ff9f

Comment by Gerrit Updater [ 13/Sep/18 ]

Minh Diep (mdiep@whamcloud.com) uploaded a new patch: https://review.whamcloud.com/33160
Subject: LU-9934 build: address issues raised by gcc7
Project: fs/lustre-release
Branch: b2_10
Current Patch Set: 1
Commit: 3b90539df347a9669bda22691855f98b4f7c06b1

Generated at Sat Feb 10 02:30:36 UTC 2024 using Jira 9.4.14#940014-sha1:734e6822bbf0d45eff9af51f82432957f73aa32c.