pastebin - collaborative debugging tool
rovema.kpaste.net RSS


msnfs41client: Patches for realistic owner/owner_group buffers, WinSG fixes, more tests+misc, 2024-07-23
Posted by Anonymous on Tue 23rd Jul 2024 18:10
raw | new post

  1. From 2cbca275ca05f07ca670faf94a9039d8f82b22c1 Mon Sep 17 00:00:00 2001
  2. From: Roland Mainz <roland.mainz@nrubsig.org>
  3. Date: Tue, 23 Jul 2024 13:54:54 +0200
  4. Subject: [PATCH 1/5] daemon: Add |NFS4_FATTR4_OWNER_LIMIT| as limit for
  5.  owner/owner_group fields
  6.  
  7. Add |NFS4_FATTR4_OWNER_LIMIT| as limit for owner/owner_group fields.
  8. Previously we used |NFS4_OPAQUE_LIMIT|, which was larger than
  9. Win32's practical limit of |256|.
  10.  
  11. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  12. ---
  13. daemon/acl.c         |  6 +++---
  14.  daemon/name_cache.c  |  4 ++--
  15.  daemon/nfs41_const.h |  8 ++++++++
  16.  daemon/nfs41_types.h |  6 +++---
  17.  daemon/nfs41_xdr.c   | 10 +++++-----
  18.  daemon/open.c        |  3 ++-
  19.  6 files changed, 23 insertions(+), 14 deletions(-)
  20.  
  21. diff --git a/daemon/acl.c b/daemon/acl.c
  22. index 6facd54..1a4f312 100644
  23. --- a/daemon/acl.c
  24. +++ b/daemon/acl.c
  25. @@ -296,7 +296,7 @@ static int handle_getacl(void *daemon_context, nfs41_upcall *upcall)
  26.      PSID *sids = NULL;
  27.      PSID osid = NULL, gsid = NULL;
  28.      DWORD sid_len;
  29. -    char owner[NFS4_OPAQUE_LIMIT+1], group[NFS4_OPAQUE_LIMIT+1];
  30. +    char owner[NFS4_FATTR4_OWNER_LIMIT+1], group[NFS4_FATTR4_OWNER_LIMIT+1];
  31.      nfsacl41 acl = { 0 };
  32.  
  33.      DPRINTF(ACLLVL1, ("--> handle_getacl(state->path.path='%s')\n",
  34. @@ -1323,8 +1323,8 @@ static int handle_setacl(void *daemon_context, nfs41_upcall *upcall)
  35.      nfsacl41 nfs4_acl = { 0 };
  36.      PSID sid = NULL, gsid = NULL;
  37.      BOOL sid_default, gsid_default;
  38. -    char ownerbuf[NFS4_OPAQUE_LIMIT+1];
  39. -    char groupbuf[NFS4_OPAQUE_LIMIT+1];
  40. +    char ownerbuf[NFS4_FATTR4_OWNER_LIMIT+1];
  41. +    char groupbuf[NFS4_FATTR4_OWNER_LIMIT+1];
  42.  
  43.      DPRINTF(ACLLVL1, ("--> handle_setacl(state->path.path='%s')\n",
  44.          state->path.path));
  45. diff --git a/daemon/name_cache.c b/daemon/name_cache.c
  46. index ec01296..a21aaf2 100644
  47. --- a/daemon/name_cache.c
  48. +++ b/daemon/name_cache.c
  49. @@ -98,8 +98,8 @@ struct attr_cache_entry {
  50.      unsigned                type : 4;
  51.      unsigned                invalidated : 1;
  52.      unsigned                delegated : 1;
  53. -    char                    owner[NFS4_OPAQUE_LIMIT+1];
  54. -    char                    owner_group[NFS4_OPAQUE_LIMIT+1];
  55. +    char                    owner[NFS4_FATTR4_OWNER_LIMIT+1];
  56. +    char                    owner_group[NFS4_FATTR4_OWNER_LIMIT+1];
  57.  };
  58.  #define ATTR_ENTRY_SIZE sizeof(struct attr_cache_entry)
  59.  
  60. diff --git a/daemon/nfs41_const.h b/daemon/nfs41_const.h
  61. index 7312cd6..2b599fd 100644
  62. --- a/daemon/nfs41_const.h
  63. +++ b/daemon/nfs41_const.h
  64. @@ -35,6 +35,14 @@
  65.  #define NFS4_EASIZE             256
  66.  #define NFS4_EANAME_SIZE        128
  67.  
  68. +/*
  69. + * |NFS4_FATTR4_OWNER_LIMIT| - limits for
  70. + * |fattr4_owner|+|fattr4_owner_group|
  71. + * While the Linux implementation uses |NFS4_OPAQUE_LIMIT|(=1024)
  72. + * the *practical* limit on Windows is 256.
  73. + * This also affects memory usage, so a lower limit is better.
  74. + */
  75. +#define NFS4_FATTR4_OWNER_LIMIT (256)
  76.  
  77.  #define NFS41_MAX_FILEIO_SIZE   (1024 * 1024)
  78.  #define NFS41_MAX_SERVER_CACHE  1024
  79. diff --git a/daemon/nfs41_types.h b/daemon/nfs41_types.h
  80. index 5007e77..21ba34a 100644
  81. --- a/daemon/nfs41_types.h
  82. +++ b/daemon/nfs41_types.h
  83. @@ -127,7 +127,7 @@ typedef struct __nfsace4 {
  84.      uint32_t        acetype;
  85.      uint32_t        aceflag;
  86.      uint32_t        acemask;
  87. -    char            who[NFS4_OPAQUE_LIMIT];
  88. +    char            who[NFS4_FATTR4_OWNER_LIMIT];
  89.  } nfsace4;
  90.  
  91.  typedef struct __nfsacl41 {
  92. @@ -238,8 +238,8 @@ typedef struct __nfs41_file_info {
  93.      uint32_t                aclsupport;
  94.  
  95.      /* Buffers */
  96. -    char owner_buf[NFS4_OPAQUE_LIMIT+1];
  97. -    char owner_group_buf[NFS4_OPAQUE_LIMIT+1];
  98. +    char owner_buf[NFS4_FATTR4_OWNER_LIMIT+1];
  99. +    char owner_group_buf[NFS4_FATTR4_OWNER_LIMIT+1];
  100.  } nfs41_file_info;
  101.  
  102.  #endif /* !__NFS41_DAEMON_TYPES_H__ */
  103. diff --git a/daemon/nfs41_xdr.c b/daemon/nfs41_xdr.c
  104. index cbca392..cbfbb17 100644
  105. --- a/daemon/nfs41_xdr.c
  106. +++ b/daemon/nfs41_xdr.c
  107. @@ -311,7 +311,7 @@ static bool_t xdr_nfsace4(
  108.      if (xdr->x_op == XDR_FREE)
  109.          return TRUE;
  110.  
  111. -    return xdr_string(xdr, &who, NFS4_OPAQUE_LIMIT);
  112. +    return xdr_string(xdr, &who, NFS4_FATTR4_OWNER_LIMIT);
  113.  }
  114.  
  115.  static bool_t xdr_nfsdacl41(
  116. @@ -1835,7 +1835,7 @@ static bool_t decode_file_attrs(
  117.              char *ptr = info->owner;
  118.              uint32_t owner_len;
  119.              if (!xdr_bytes(xdr, &ptr, &owner_len,
  120. -                            NFS4_OPAQUE_LIMIT)) {
  121. +                            NFS4_FATTR4_OWNER_LIMIT)) {
  122.                  info->owner = NULL;
  123.                  return FALSE;
  124.              }
  125. @@ -1851,7 +1851,7 @@ static bool_t decode_file_attrs(
  126.              char *ptr = info->owner_group;
  127.              uint32_t owner_group_len;
  128.              if (!xdr_bytes(xdr, &ptr, &owner_group_len,
  129. -                            NFS4_OPAQUE_LIMIT)) {
  130. +                            NFS4_FATTR4_OWNER_LIMIT)) {
  131.                  info->owner_group = NULL;
  132.                  return FALSE;
  133.              }
  134. @@ -2672,7 +2672,7 @@ static bool_t encode_file_attrs(
  135.              char *ptr = &info->owner[0];
  136.              uint32_t owner_len = (uint32_t)strlen(info->owner);
  137.              if (!xdr_bytes(&localxdr, &ptr, &owner_len,
  138. -                            NFS4_OPAQUE_LIMIT))
  139. +                            NFS4_FATTR4_OWNER_LIMIT))
  140.                  return FALSE;
  141.              attrs->attrmask.arr[1] |= FATTR4_WORD1_OWNER;
  142.          }
  143. @@ -2680,7 +2680,7 @@ static bool_t encode_file_attrs(
  144.              char *ptr = &info->owner_group[0];
  145.              uint32_t owner_group_len = (uint32_t)strlen(info->owner_group);
  146.              if (!xdr_bytes(&localxdr, &ptr, &owner_group_len,
  147. -                            NFS4_OPAQUE_LIMIT))
  148. +                            NFS4_FATTR4_OWNER_LIMIT))
  149.                  return FALSE;
  150.              attrs->attrmask.arr[1] |= FATTR4_WORD1_OWNER_GROUP;
  151.          }
  152. diff --git a/daemon/open.c b/daemon/open.c
  153. index dfaf17f..6769e93 100644
  154. --- a/daemon/open.c
  155. +++ b/daemon/open.c
  156. @@ -775,7 +775,8 @@ static int handle_open(void *daemon_context, nfs41_upcall *upcall)
  157.          args->changeattr = info.change;
  158.  
  159.  #ifdef NFS41_DRIVER_FEATURE_LOCAL_UIDGID_IN_NFSV3ATTRIBUTES
  160. -        char owner[NFS4_OPAQUE_LIMIT], owner_group[NFS4_OPAQUE_LIMIT];
  161. +        char owner[NFS4_FATTR4_OWNER_LIMIT+1];
  162. +        char owner_group[NFS4_FATTR4_OWNER_LIMIT+1];
  163.          uid_t map_uid = ~0UL;
  164.          gid_t map_gid = ~0UL;
  165.          char *at_ch; /* pointer to '@' */
  166. --
  167. 2.45.1
  168.  
  169. From 489456ae4ca85be413fa9aaaa1d60d2c86118724 Mon Sep 17 00:00:00 2001
  170. From: Roland Mainz <roland.mainz@nrubsig.org>
  171. Date: Tue, 23 Jul 2024 14:09:30 +0200
  172. Subject: [PATCH 2/5] daemon,dll,tests: |GETTOKINFO_EXTRA_BUFFER| does not fit
  173.  50 group SIDs
  174.  
  175. |GETTOKINFO_EXTRA_BUFFER| does not fit 50 group SIDs, as seen with
  176. winsg.exe in an enterprise network.
  177. As fix we increase the buffer size from |2048| to |8192|.
  178.  
  179. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  180. ---
  181. daemon/accesstoken.c | 4 ++--
  182.  dll/nfs41_np.c       | 4 ++--
  183.  tests/winsg/winsg.c  | 4 ++--
  184.  3 files changed, 6 insertions(+), 6 deletions(-)
  185.  
  186. diff --git a/daemon/accesstoken.c b/daemon/accesstoken.c
  187. index 4ad62b1..c212c91 100644
  188. --- a/daemon/accesstoken.c
  189. +++ b/daemon/accesstoken.c
  190. @@ -37,10 +37,10 @@
  191.   * |ERROR_INSUFFICIENT_BUFFER| if you just pass the |sizeof(TOKEN_*)|
  192.   * value.
  193.   * Instead of calling |GetTokenInformation()| with |NULL| arg to
  194. - * obtain the size to allocate we just provide 2048 bytes of extra
  195. + * obtain the size to allocate we just provide 8192 bytes of extra
  196.   * space after the |TOKEN_*| size, and pray it is enough.
  197.   */
  198. -#define GETTOKINFO_EXTRA_BUFFER (2048)
  199. +#define GETTOKINFO_EXTRA_BUFFER (8192)
  200.  
  201.  bool get_token_user_name(HANDLE tok, char *out_buffer)
  202.  {
  203. diff --git a/dll/nfs41_np.c b/dll/nfs41_np.c
  204. index 6e24e21..5538ab3 100644
  205. --- a/dll/nfs41_np.c
  206. +++ b/dll/nfs41_np.c
  207. @@ -93,10 +93,10 @@ bool equal_luid(LUID *l1, LUID *l2)
  208.   * |ERROR_INSUFFICIENT_BUFFER| if you just pass the |sizeof(TOKEN_*)|
  209.   * value.
  210.   * Instead of calling |GetTokenInformation()| with |NULL| arg to
  211. - * obtain the size to allocate we just provide 2048 bytes of extra
  212. + * obtain the size to allocate we just provide 8192 bytes of extra
  213.   * space after the |TOKEN_*| size, and pray it is enough.
  214.   */
  215. -#define GETTOKINFO_EXTRA_BUFFER (2048)
  216. +#define GETTOKINFO_EXTRA_BUFFER (8192)
  217.  
  218.  static
  219.  bool get_token_authenticationid(HANDLE tok, LUID *out_authenticationid)
  220. diff --git a/tests/winsg/winsg.c b/tests/winsg/winsg.c
  221. index a0f18d8..da5c3a8 100644
  222. --- a/tests/winsg/winsg.c
  223. +++ b/tests/winsg/winsg.c
  224. @@ -80,10 +80,10 @@
  225.   * always fails in Win10 with |ERROR_INSUFFICIENT_BUFFER| if you
  226.   * just pass the |sizeof(TOKEN_*)| value. Instead of calling
  227.   * |GetTokenInformation()| with |NULL| arg to obtain the size to
  228. - * allocate we just provide 2048 bytes of extra space after the
  229. + * allocate we just provide 8192 bytes of extra space after the
  230.   * |TOKEN_*| size, and pray it is enough
  231.   */
  232. -#define GETTOKINFO_EXTRA_BUFFER (2048)
  233. +#define GETTOKINFO_EXTRA_BUFFER (8192)
  234.  
  235.  D(
  236.  static
  237. --
  238. 2.45.1
  239.  
  240. From ed793ae5091f64bf74abeb7072cefa8ea65117ef Mon Sep 17 00:00:00 2001
  241. From: Cedric Blancher <cedric.blancher@gmail.com>
  242. Date: Tue, 23 Jul 2024 14:16:29 +0200
  243. Subject: [PATCH 3/5] tests/winsg: winsg.exe crashes with D() debugging
  244.  enabled.
  245.  
  246. winsg.exe crashes with D() debugging enabled.
  247.  
  248. Signed-off-by: Roland Mainz <roland.mainz@nrubsig.org>
  249. ---
  250. tests/winsg/winsg.c | 5 ++++-
  251.  1 file changed, 4 insertions(+), 1 deletion(-)
  252.  
  253. diff --git a/tests/winsg/winsg.c b/tests/winsg/winsg.c
  254. index da5c3a8..4860710 100644
  255. --- a/tests/winsg/winsg.c
  256. +++ b/tests/winsg/winsg.c
  257. @@ -428,7 +428,10 @@ int main(int ac, char *av[])
  258.          "# shelltype=%d, cmd_arg_index=%d, "
  259.          "av[cmd_arg_index]='%s', "
  260.          "new group name '%s'\n",
  261. -        (int)st, cmd_arg_index, av[cmd_arg_index], newgrpname));
  262. +        (int)st,
  263. +        cmd_arg_index,
  264. +        ((cmd_arg_index >= 0)?av[cmd_arg_index]:"<negative-av-idx>"),
  265. +        newgrpname));
  266.  
  267.      if (!OpenProcessToken(GetCurrentProcess(),
  268.          TOKEN_QUERY|TOKEN_ADJUST_DEFAULT|TOKEN_DUPLICATE,
  269. --
  270. 2.45.1
  271.  
  272. From 40f50fbffef38c8f5c062d7719218e3d32e6bed4 Mon Sep 17 00:00:00 2001
  273. From: Cedric Blancher <cedric.blancher@gmail.com>
  274. Date: Tue, 23 Jul 2024 14:20:02 +0200
  275. Subject: [PATCH 4/5] tests/winsg: winsg -L fails with "print_groups_in_token:
  276.  LookupAccountSidA() failed, status=122."
  277.  
  278. winsg.exe -L fails with "print_groups_in_token: LookupAccountSidA()
  279. failed, status=122." after printing the first group, because the
  280. buffer size arguments passed to LookupAccountSidA() must be reset
  281. to the original values after each iteration.
  282.  
  283. Signed-off-by: Roland Mainz <roland.mainz@nrubsig.org>
  284. ---
  285. tests/winsg/winsg.c | 7 +++++--
  286.  1 file changed, 5 insertions(+), 2 deletions(-)
  287.  
  288. diff --git a/tests/winsg/winsg.c b/tests/winsg/winsg.c
  289. index 4860710..b6d332c 100644
  290. --- a/tests/winsg/winsg.c
  291. +++ b/tests/winsg/winsg.c
  292. @@ -163,9 +163,9 @@ int print_groups_in_token(HANDLE tok)
  293.      DWORD tokdatalen;
  294.      PTOKEN_GROUPS ptgroups;
  295.      char namebuffer[GNLEN+1];
  296. -    DWORD namesize = GNLEN+1;
  297. +    DWORD namesize;
  298.      char domainbuffer[UNLEN+1];
  299. -    DWORD domainbuffer_size = sizeof(domainbuffer);
  300. +    DWORD domainbuffer_size;
  301.      SID_NAME_USE name_use;
  302.  
  303.      tokdatalen = sizeof(TOKEN_GROUPS)+GETTOKINFO_EXTRA_BUFFER;
  304. @@ -189,6 +189,9 @@ int print_groups_in_token(HANDLE tok)
  305.              continue;
  306.          }
  307.  
  308. +        namesize = sizeof(namebuffer)-1;
  309. +        domainbuffer_size = sizeof(domainbuffer)-1;
  310. +
  311.          if (!LookupAccountSidA(NULL, ptgroups->Groups[i].Sid,
  312.              namebuffer, &namesize, domainbuffer, &domainbuffer_size, &name_use)) {
  313.              D((void)fprintf(stderr, "print_groups_in_token: "
  314. --
  315. 2.45.1
  316.  
  317. From 99f41ba7044e9f7326d4f59e03069a2b7ec70da2 Mon Sep 17 00:00:00 2001
  318. From: Roland Mainz <roland.mainz@nrubsig.org>
  319. Date: Tue, 23 Jul 2024 18:56:32 +0200
  320. Subject: [PATCH 5/5] tests: nfsbuildtest.ksh93 should have a "bash" target
  321.  
  322. nfsbuildtest.ksh93 should have a "bash" target
  323.  
  324. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  325. ---
  326. tests/nfsbuildtest/nfsbuildtest.ksh93 | 441 ++++++++++++++++++++------
  327.  1 file changed, 340 insertions(+), 101 deletions(-)
  328.  
  329. diff --git a/tests/nfsbuildtest/nfsbuildtest.ksh93 b/tests/nfsbuildtest/nfsbuildtest.ksh93
  330. index fe7d492..e7b7003 100644
  331. --- a/tests/nfsbuildtest/nfsbuildtest.ksh93
  332. +++ b/tests/nfsbuildtest/nfsbuildtest.ksh93
  333. @@ -3,129 +3,368 @@
  334.  #
  335.  # nfsbuildtest.ksh93
  336.  #
  337. -# Simple NFSv4 torture test by building gcc in parallel
  338. +# Simple NFSv4 torture test by building { bash, gcc } in parallel
  339.  # on a NFS filesystem
  340.  #
  341. -set -o xtrace
  342. -set -o errexit
  343. -set -o nounset
  344.  
  345.  #
  346. -# build config
  347. +# Usage:
  348. +# - build bash:
  349. +#   $ ksh93 nfsbuildtest.ksh93 bash clean
  350. +#   $ ksh93 nfsbuildtest.ksh93 bash createcache
  351. +#   $ ksh93 nfsbuildtest.ksh93 bash build
  352.  #
  353. -typeset config_cp_p_function_not_implemented_workaround=false
  354. -typeset config_use_posix_ksh93_builtins=true
  355. -
  356. -compound gitdata=(
  357. -       typeset url='git://repo.or.cz/gcc.git'
  358. -        # use fixed git tag, so build times are compareable
  359. -       typeset tag='releases/gcc-13.1.0'
  360. -)
  361. -
  362. -typeset -a configure_options=(
  363. -       # Per irc://irc.oftc.net/#gcc:
  364. -       # ".. pch is broken on windows as allocation using the fixed
  365. -       # address might not succeed in general and there is fixed
  366. -       # retry loop using delay that kills all performance
  367. -       # benefits..."
  368. -       '--disable-libstdcxx-pch'
  369. -)
  370. -
  371. -#
  372. -# temp dir setup
  373. +# - build gcc:
  374. +#   $ ksh93 nfsbuildtest.ksh93 gcc clean
  375. +#   $ ksh93 nfsbuildtest.ksh93 gcc createcache
  376. +#   $ ksh93 nfsbuildtest.ksh93 gcc build
  377.  #
  378.  
  379. -# fixme: Does not work with NFSv4.1 filesystem from exported Linux tmpfs - why ?
  380. -#tmpdir='/cygdrive/m/tmpdir'
  381. -#mkdir -p "$tmpdir"
  382. -#chmod a=rwxt "$tmpdir"
  383. -#if [[ -d "$tmpdir" && -w "$tmpdir" ]] ; then
  384. -#      export TMPDIR="$tmpdir"
  385. -#fi
  386. +function gcc_createcache
  387. +{
  388. +       set -o xtrace
  389. +       set -o errexit
  390. +       set -o nounset
  391.  
  392. -#
  393. -# print user info
  394. -#
  395. -id -a
  396. -pwd
  397. +       mkdir -p 'gitbundles'
  398. +       rm -f 'gitbundles/gcc.bundle'
  399.  
  400. -#
  401. -# source checkout
  402. -#
  403. +       git -c checkout.workers=16 clone git://repo.or.cz/gcc.git
  404. +       cd gcc
  405. +       git config --global --add safe.directory "$PWD"
  406. +       git bundle create '../gitbundles/gcc.bundle' --all
  407. +       git config --global --unset safe.directory "$PWD"
  408. +       cd ..
  409. +       rm -Rf gcc
  410.  
  411. -#time git -c checkout.workers=16 clone -b "${gitdata.tag}" --single-branch git://gcc.gnu.org/git/gcc.git
  412. -#time git -c checkout.workers=16 clone -b "${gitdata.tag}" --single-branch https://github.com/gcc-mirror/gcc.git
  413. -
  414. -if [[ -f '../gitbundles/gcc.bundle' ]] ; then
  415. -       # Use local bundle as cache,
  416. -        # so build times only depend on local filesystem performance
  417. -        # and not HTTPS speed
  418. -        #
  419. -       # The bundle was created like this:
  420. -       # ---- snip ----
  421. -       # git clone git://repo.or.cz/gcc.git
  422. -       # cd gcc
  423. -       # git bundle create '../gitbundles/gcc.bundle' --all
  424. -       # cd ..
  425. -       # rm -Rf gcc
  426. -       # ---- snip ----
  427. -       time git -c checkout.workers=16 clone -b "${gitdata.tag}" --single-branch '../gitbundles/gcc.bundle'
  428. -else
  429. -       time git -c checkout.workers=16 clone -b "${gitdata.tag}" --single-branch "${gitdata.url}"
  430. -fi
  431. -
  432. -cd "$PWD/gcc/"
  433. -
  434. -if $config_use_posix_ksh93_builtins ; then
  435. -       PATH="/usr/ast/bin:/opt/ast/bin:$PATH"
  436. -fi
  437. +       return 0
  438. +}
  439.  
  440. -#
  441. -# patch sources and configure build
  442. -#
  443.  
  444. -# Cygwin: workaround for configure using cp -p where ln -s should be used
  445. -# (this is an automake/autoconf issue, they should trust Cygwin and not use
  446. -# ancient workarounds for issues which no longer exists)
  447. -(set -o xtrace ; sed -i "s/as_ln_s='cp -pR'/as_ln_s='ln -s'/g" $(find . -name 'configure') )
  448. +function gcc_build
  449. +{
  450. +       set -o xtrace
  451. +       set -o errexit
  452. +       set -o nounset
  453. +
  454. +       #
  455. +       # build config
  456. +       #
  457. +       typeset config_cp_p_function_not_implemented_workaround=false
  458. +       typeset config_use_posix_ksh93_builtins=true
  459. +
  460. +       compound gitdata=(
  461. +               typeset url='git://repo.or.cz/gcc.git'
  462. +               # use fixed git tag, so build times are compareable
  463. +               typeset tag='releases/gcc-13.1.0'
  464. +       )
  465. +
  466. +       typeset -a configure_options=(
  467. +               # Per irc://irc.oftc.net/#gcc:
  468. +               # ".. pch is broken on windows as allocation using the fixed
  469. +               # address might not succeed in general and there is fixed
  470. +               # retry loop using delay that kills all performance
  471. +               # benefits..."
  472. +               '--disable-libstdcxx-pch'
  473. +       )
  474. +
  475. +       #
  476. +       # temp dir setup
  477. +       #
  478. +
  479. +       # fixme: Does not work with NFSv4.1 filesystem from exported Linux tmpfs - why ?
  480. +       #tmpdir='/cygdrive/m/tmpdir'
  481. +       #mkdir -p "$tmpdir"
  482. +       #chmod a=rwxt "$tmpdir"
  483. +       #if [[ -d "$tmpdir" && -w "$tmpdir" ]] ; then
  484. +       #       export TMPDIR="$tmpdir"
  485. +       #fi
  486. +
  487. +       #
  488. +       # print user info
  489. +       #
  490. +       id -a
  491. +       pwd
  492. +
  493. +       #
  494. +       # source checkout
  495. +       #
  496. +
  497. +       #time git -c checkout.workers=16 clone -b "${gitdata.tag}" --single-branch git://gcc.gnu.org/git/gcc.git
  498. +       #time git -c checkout.workers=16 clone -b "${gitdata.tag}" --single-branch https://github.com/gcc-mirror/gcc.git
  499. +
  500. +       if [[ -f '../gitbundles/gcc.bundle' ]] ; then
  501. +               # Use local bundle as cache,
  502. +               # so build times only depend on local filesystem performance
  503. +               # and not HTTPS speed
  504. +               time git -c checkout.workers=16 clone -b "${gitdata.tag}" --single-branch '../gitbundles/gcc.bundle'
  505. +       else
  506. +               time git -c checkout.workers=16 clone -b "${gitdata.tag}" --single-branch "${gitdata.url}"
  507. +       fi
  508. +
  509. +       cd "$PWD/gcc/"
  510.  
  511. -if $config_use_posix_ksh93_builtins ; then
  512. -       (set -o xtrace ; sed -i "s/\/bin\/sh/\/bin\/ksh93/g" $(find . -name 'configure') )
  513. -fi
  514. +       if $config_use_posix_ksh93_builtins ; then
  515. +               PATH="/usr/ast/bin:/opt/ast/bin:$PATH"
  516. +       fi
  517. +
  518. +       #
  519. +       # patch sources and configure build
  520. +       #
  521.  
  522. -if $config_use_posix_ksh93_builtins ; then
  523. -       ksh93 ./configure "${configure_options[@]}"
  524. -else
  525. -       bash ./configure "${configure_options[@]}"
  526. -fi
  527. +       # Cygwin: workaround for configure using cp -p where ln -s should be used
  528. +       # (this is an automake/autoconf issue, they should trust Cygwin and not use
  529. +       # ancient workarounds for issues which no longer exists)
  530. +       (set -o xtrace ; sed -i "s/as_ln_s='cp -pR'/as_ln_s='ln -s'/g" $(find . -name 'configure') )
  531. +
  532. +       if $config_use_posix_ksh93_builtins ; then
  533. +               (set -o xtrace ; sed -i "s/\/bin\/sh/\/bin\/ksh93/g" $(find . -name 'configure') )
  534. +       fi
  535.  
  536. -if $config_cp_p_function_not_implemented_workaround ; then
  537. -       # workaround for $ cp -p # failing with "Function not
  538. -       # implemented" in older versions of ms-nfs41-client
  539.         if $config_use_posix_ksh93_builtins ; then
  540. -               (
  541. -                       set -o xtrace
  542. -                       sed -i -r 's/(cp.*)([[:space:]]+-p[[:space:]]+)/\2 -A pt /g' \
  543. +               export CONFIG_SHELL=/usr/bin/ksh93
  544. +               ksh93 ./configure "${configure_options[@]}"
  545. +       else
  546. +               export CONFIG_SHELL=/usr/bin/bash
  547. +               bash ./configure "${configure_options[@]}"
  548. +       fi
  549. +
  550. +       if $config_cp_p_function_not_implemented_workaround ; then
  551. +               # workaround for $ cp -p # failing with "Function not
  552. +               # implemented" in older versions of ms-nfs41-client
  553. +               if $config_use_posix_ksh93_builtins ; then
  554. +                       (
  555. +                               set -o xtrace
  556. +                               sed -i -r 's/(cp.*)([[:space:]]+-p[[:space:]]+)/\2 -A pt /g' \
  557. +                                       $(find . -name 'Makefile' -o -name 'Makefile.in')
  558. +                       )
  559. +               else
  560. +                       (
  561. +                               set -o xtrace ; sed -i -r 's/(cp.*)([[:space:]]+-p[[:space:]]+)/\2--no-preserve=ownership /g' \
  562.                                 $(find . -name 'Makefile' -o -name 'Makefile.in')
  563. -               )
  564. +                       )
  565. +               fi
  566. +       fi
  567. +
  568. +       if $config_use_posix_ksh93_builtins ; then
  569. +               # replace /bin/sh with /bin/ksh93 for speed
  570. +               (set -o xtrace ; sed -i -r 's/\/bin\/sh/\/bin\/ksh93/g' \
  571. +                       $(find . -name 'Makefile' -o -name 'Makefile.in') )
  572. +       fi
  573. +
  574. +       #
  575. +       # build gcc
  576. +       #
  577. +       time ksh93 -c 'export SHELL=/bin/ksh93 ; (yes | make -j8 all)'
  578. +       echo $?
  579. +
  580. +       echo "#Done."
  581. +       return 0
  582. +}
  583. +
  584. +
  585. +function gcc_clean
  586. +{
  587. +       set -o xtrace
  588. +       set -o errexit
  589. +       set -o nounset
  590. +
  591. +       rm -Rf gcc
  592. +       return 0
  593. +}
  594. +
  595. +
  596. +function bash_createcache
  597. +{
  598. +       set -o xtrace
  599. +       set -o errexit
  600. +       set -o nounset
  601. +
  602. +       mkdir -p 'gitbundles'
  603. +       rm -f 'gitbundles/bash.bundle'
  604. +
  605. +       git -c checkout.workers=16 clone 'https://github.com/bminor/bash.git'
  606. +       cd bash
  607. +       git config --global --add safe.directory "$PWD"
  608. +       git bundle create '../gitbundles/bash.bundle' --all
  609. +       git config --global --unset safe.directory "$PWD"
  610. +       cd ..
  611. +       rm -Rf bash
  612. +
  613. +       return 0
  614. +}
  615. +
  616. +
  617. +function bash_build
  618. +{
  619. +       set -o xtrace
  620. +       set -o errexit
  621. +       set -o nounset
  622. +
  623. +       #
  624. +       # build config
  625. +       #
  626. +       typeset config_cp_p_function_not_implemented_workaround=false
  627. +       typeset config_use_posix_ksh93_builtins=true
  628. +
  629. +       compound gitdata=(
  630. +               typeset url='https://github.com/bminor/bash.git'
  631. +               # use fixed git tag, so build times are compareable
  632. +               typeset tag='master'
  633. +       )
  634. +
  635. +       typeset -a configure_options=(
  636. +               '--with-curses'
  637. +       )
  638. +
  639. +       #
  640. +       # temp dir setup
  641. +       #
  642. +
  643. +       # fixme: Does not work with NFSv4.1 filesystem from exported Linux tmpfs - why ?
  644. +       #tmpdir='/cygdrive/m/tmpdir'
  645. +       #mkdir -p "$tmpdir"
  646. +       #chmod a=rwxt "$tmpdir"
  647. +       #if [[ -d "$tmpdir" && -w "$tmpdir" ]] ; then
  648. +       #       export TMPDIR="$tmpdir"
  649. +       #fi
  650. +
  651. +       #
  652. +       # print user info
  653. +       #
  654. +       id -a
  655. +       pwd
  656. +
  657. +       #
  658. +       # source checkout
  659. +       #
  660. +
  661. +       if [[ -f '../gitbundles/bash.bundle' ]] ; then
  662. +               # Use local bundle as cache,
  663. +               # so build times only depend on local filesystem performance
  664. +               # and not HTTPS speed
  665. +               time git -c checkout.workers=16 clone -b "${gitdata.tag}" --single-branch '../gitbundles/bash.bundle'
  666.         else
  667. -               (
  668. -                       set -o xtrace ; sed -i -r 's/(cp.*)([[:space:]]+-p[[:space:]]+)/\2--no-preserve=ownership /g' \
  669. +               time git -c checkout.workers=16 clone -b "${gitdata.tag}" --single-branch "${gitdata.url}"
  670. +       fi
  671. +
  672. +       cd "$PWD/bash/"
  673. +
  674. +       if $config_use_posix_ksh93_builtins ; then
  675. +               PATH="/usr/ast/bin:/opt/ast/bin:$PATH"
  676. +       fi
  677. +
  678. +       #
  679. +       # patch sources and configure build
  680. +       #
  681. +
  682. +       # Cygwin: workaround for configure using cp -p where ln -s should be used
  683. +       # (this is an automake/autoconf issue, they should trust Cygwin and not use
  684. +       # ancient workarounds for issues which no longer exists)
  685. +       (set -o xtrace ; sed -i "s/as_ln_s='cp -pR'/as_ln_s='ln -s'/g" $(find . -name 'configure') )
  686. +
  687. +       if $config_use_posix_ksh93_builtins ; then
  688. +               (set -o xtrace ; sed -i "s/\/bin\/sh/\/bin\/ksh93/g" $(find . -name 'configure') )
  689. +       fi
  690. +
  691. +       if $config_use_posix_ksh93_builtins ; then
  692. +               CONFIG_SHELL=/usr/bin/ksh93 ksh93 ./configure "${configure_options[@]}"
  693. +       else
  694. +               CONFIG_SHELL=/usr/bin/bash bash ./configure "${configure_options[@]}"
  695. +       fi
  696. +
  697. +       if $config_cp_p_function_not_implemented_workaround ; then
  698. +               # workaround for $ cp -p # failing with "Function not
  699. +               # implemented" in older versions of ms-nfs41-client
  700. +               if $config_use_posix_ksh93_builtins ; then
  701. +                       (
  702. +                               set -o xtrace
  703. +                               sed -i -r 's/(cp.*)([[:space:]]+-p[[:space:]]+)/\2 -A pt /g' \
  704. +                                       $(find . -name 'Makefile' -o -name 'Makefile.in')
  705. +                       )
  706. +               else
  707. +                       (
  708. +                               set -o xtrace ; sed -i -r 's/(cp.*)([[:space:]]+-p[[:space:]]+)/\2--no-preserve=ownership /g' \
  709.                                 $(find . -name 'Makefile' -o -name 'Makefile.in')
  710. -               )
  711. +                       )
  712. +               fi
  713.         fi
  714. -fi
  715.  
  716. -if $config_use_posix_ksh93_builtins ; then
  717. -       # replace /bin/sh with /bin/ksh93 for speed
  718. -       (set -o xtrace ; sed -i -r 's/\/bin\/sh/\/bin\/ksh93/g' \
  719. -               $(find . -name 'Makefile' -o -name 'Makefile.in') )
  720. -fi
  721. +       if $config_use_posix_ksh93_builtins ; then
  722. +               # replace /bin/sh with /bin/ksh93 for speed
  723. +               (set -o xtrace ; sed -i -r 's/\/bin\/sh/\/bin\/ksh93/g' \
  724. +                       $(find . -name 'Makefile' -o -name 'Makefile.in') )
  725. +       fi
  726. +
  727. +       #
  728. +       # build bash
  729. +       #
  730. +       time ksh93 -c 'export SHELL=/bin/ksh93 ; bmake -j8'
  731. +       echo $?
  732. +
  733. +       echo "#Done."
  734. +       return 0
  735. +}
  736. +
  737. +
  738. +function bash_clean
  739. +{
  740. +       set -o xtrace
  741. +       set -o errexit
  742. +       set -o nounset
  743. +
  744. +       rm -Rf bash
  745. +       return 0
  746. +}
  747. +
  748. +builtin id
  749. +builtin mkdir
  750. +
  751. +function main
  752. +{
  753. +       typeset target="$1"
  754. +       typeset subcmd="$2"
  755. +
  756. +       case "${target}_${subcmd}" in
  757. +               'gcc_createcache')
  758. +                       gcc_createcache
  759. +                       return $?
  760. +                       ;;
  761. +               'gcc_build')
  762. +                       gcc_build
  763. +                       return $?
  764. +                       ;;
  765. +               'gcc_clean')
  766. +                       gcc_clean
  767. +                       return $?
  768. +                       ;;
  769. +               'bash_createcache')
  770. +                       bash_createcache
  771. +                       return $?
  772. +                       ;;
  773. +               'bash_build')
  774. +                       bash_build
  775. +                       return $?
  776. +                       ;;
  777. +               'bash_clean')
  778. +                       bash_clean
  779. +                       return $?
  780. +                       ;;
  781. +               *)
  782. +                       print -u2 -f $"%s: Unknown %q/%q combination." \
  783. +                               "$0" "${target}" "${subcmd}"
  784. +                       return 1
  785. +                       ;;
  786. +       esac
  787. +
  788. +       # not reached
  789. +       return 1
  790. +}
  791.  
  792.  #
  793. -# build gcc
  794. +# main
  795.  #
  796. -time ksh93 -c 'export SHELL=/bin/ksh93 ; (yes | make -j8 all)'
  797. -echo $?
  798. +main "$@"
  799. +return $?
  800.  
  801. -echo "#Done."
  802. +# EOF.
  803. --
  804. 2.45.1

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}




All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at