Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 850118 - net-misc/nextcloud-client-3.5.1 - /.../c_private.h: error: _stat was not declared in this scope
Summary: net-misc/nextcloud-client-3.5.1 - /.../c_private.h: error: _stat was not decl...
Status: RESOLVED DUPLICATE of bug 890072
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Bernard Cafarelli
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-06-06 16:23 UTC by Toralf Förster
Modified: 2023-02-11 00:04 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
emerge-info.txt (emerge-info.txt,17.56 KB, text/plain)
2022-06-06 16:23 UTC, Toralf Förster
Details
emerge-history.txt (emerge-history.txt,136.16 KB, text/plain)
2022-06-06 16:23 UTC, Toralf Förster
Details
environment (environment,96.00 KB, text/plain)
2022-06-06 16:23 UTC, Toralf Förster
Details
etc.portage.tar.bz2 (etc.portage.tar.bz2,12.42 KB, application/x-bzip)
2022-06-06 16:23 UTC, Toralf Förster
Details
logs.tar.bz2 (logs.tar.bz2,6.15 KB, application/x-bzip)
2022-06-06 16:23 UTC, Toralf Förster
Details
net-misc:nextcloud-client-3.5.1:20220606-162228.log (net-misc:nextcloud-client-3.5.1:20220606-162228.log,39.61 KB, text/plain)
2022-06-06 16:23 UTC, Toralf Förster
Details
temp.tar.bz2 (temp.tar.bz2,26.97 KB, application/x-bzip)
2022-06-06 16:23 UTC, Toralf Förster
Details
remove -D_FORTIFY_SOURCE override completely (file_850118.txt,1.84 KB, patch)
2023-02-10 17:38 UTC, Thomas Schneider
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Toralf Förster gentoo-dev 2022-06-06 16:23:12 UTC
<command-line>: warning: "_FORTIFY_SOURCE" redefined
<built-in>: note: this is the location of the previous definition
In file included from /var/tmp/portage/net-misc/nextcloud-client-3.5.1/work/desktop-3.5.1/src/csync/vio/csync_vio_local_unix.cpp:31:
/var/tmp/portage/net-misc/nextcloud-client-3.5.1/work/desktop-3.5.1/src/csync/vio/csync_vio_local_unix.cpp: In function int _csync_vio_local_stat_mb(const mbchar_t*, csync_file_stat_t*)’:
/var/tmp/portage/net-misc/nextcloud-client-3.5.1/work/desktop-3.5.1/src/csync/std/c_private.h:88:15: error: _stat’ was not declared in this scope; did you mean stat’?
   88 | #define lstat _stat
      |               ^~~~~

  -------------------------------------------------------------------

  This is an unstable amd64 chroot image at a tinderbox (==build bot)
  name: 17.1_no_multilib-j4-20220605-170005

  -------------------------------------------------------------------

gcc-config -l:
 [1] x86_64-pc-linux-gnu-12.1.1 *
clang/llvm (if any):
clang version 14.0.4
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/lib/llvm/14/bin
/usr/lib/llvm/14
14.0.4
Python 3.9.13
Available Ruby profiles:
  [1]   ruby31 *
Available Rust versions:
  [1]   rust-1.61.0 *
The following VMs are available for generation-2:
1)	OpenJDK 17.0.3_p7 [openjdk-17]
2)	OpenJDK 8.332_p09 [openjdk-8]
*)	Eclipse Temurin JDK 17.0.3_p7 [openjdk-bin-17]
4)	Eclipse Temurin JDK 8.332_p09 [openjdk-bin-8]
Available Java Virtual Machines:
  [1]   openjdk-8 
  [2]   openjdk-17 
  [3]   openjdk-bin-8 
  [4]   openjdk-bin-17  system-vm

The Glorious Glasgow Haskell Compilation System, version 8.10.4
php cli:
  [1]   php8.1 *

  HEAD of ::gentoo
commit 314843433151b37acd811fb425ebd41937e699d5
Author: Repository mirror & CI <repomirrorci@gentoo.org>
Date:   Mon Jun 6 14:48:03 2022 +0000

    2022-06-06 14:48:03 UTC

emerge -qpvO net-misc/nextcloud-client
[ebuild  N    ] net-misc/nextcloud-client-3.5.1  USE="-doc -dolphin -nautilus -test -webengine"
Comment 1 Toralf Förster gentoo-dev 2022-06-06 16:23:14 UTC
Created attachment 783155 [details]
emerge-info.txt
Comment 2 Toralf Förster gentoo-dev 2022-06-06 16:23:15 UTC
Created attachment 783158 [details]
emerge-history.txt
Comment 3 Toralf Förster gentoo-dev 2022-06-06 16:23:16 UTC
Created attachment 783161 [details]
environment
Comment 4 Toralf Förster gentoo-dev 2022-06-06 16:23:17 UTC
Created attachment 783164 [details]
etc.portage.tar.bz2
Comment 5 Toralf Förster gentoo-dev 2022-06-06 16:23:18 UTC
Created attachment 783167 [details]
logs.tar.bz2
Comment 6 Toralf Förster gentoo-dev 2022-06-06 16:23:19 UTC
Created attachment 783170 [details]
net-misc:nextcloud-client-3.5.1:20220606-162228.log
Comment 7 Toralf Förster gentoo-dev 2022-06-06 16:23:21 UTC
Created attachment 783173 [details]
temp.tar.bz2
Comment 8 Thomas Schneider 2023-02-10 17:17:16 UTC
This bug is wildly misleading.  Upon closer inspection of CMakeError.log, I’ve found that the test for lstat() fails (thus HAVE_LSTAT is false, and through some defines, the code mentioned above ends up with the nonexistant _stat.

The reason that the lstat() test fails is however:

```
qsx@naboo /tmp 
% cat src.c
int main(void) {
#ifdef _FORTIFY_SOURCE
	return _FORTIFY_SOURCE;
#else
	return 42;
#endif
}
qsx@naboo /tmp 
% /usr/lib/ccache/bin/x86_64-pc-linux-gnu-gcc -DWITH_FPIC   -O2 -pipe -march=native -Wno-incompatible-pointer-types-discards-qualifiers -Wno-discarded-qualifiers -fstack-protector-strong -D_FORTIFY_SOURCE=2 -std=gnu99 -pedantic -pedantic-errors -Wall -Wextra -Wshadow -Wmissing-prototypes -Wunused -Wfloat-equal -Wpointer-arith -Wwrite-strings -Wformat-security -Wmissing-format-attribute -Wmissing-format-attribute -D_GNU_SOURCE -D__STDC_FORMAT_MACROS=1   -fPIC -c src.c  
<command-line>: error: "_FORTIFY_SOURCE" redefined
<built-in>: note: this is the location of the previous definition
cc1: note: unrecognized command-line option ‘-Wno-incompatible-pointer-types-discards-qualifiers’ may have been intended to silence earlier diagnostics
```

Huh.  But where?  Let’s try again, this time without `-D_FORTIFY_SOURCE=2` and `-E` instead of `-c` to see it right away.

```
qsx@naboo /tmp 
% /usr/lib/ccache/bin/x86_64-pc-linux-gnu-gcc -DWITH_FPIC   -O2 -pipe -march=native -Wno-incompatible-pointer-types-discards-qualifiers -Wno-discarded-qualifiers -fstack-protector-strong -std=gnu99 -pedantic -pedantic-errors -Wall -Wextra -Wshadow -Wmissing-prototypes -Wunused -Wfloat-equal -Wpointer-arith -Wwrite-strings -Wformat-security -Wmissing-format-attribute -Wmissing-format-attribute -D_GNU_SOURCE -D__STDC_FORMAT_MACROS=1   -fPIC -E src.c                    
# 0 "src.c"
# 0 "<built-in>"
# 0 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 0 "<command-line>" 2
# 1 "src.c"
int main(void) {

 return 3;



}
```

Well, it isn’t in `/usr/include/stdc-predef.h`, so I blame `<built-in>` and thus probably sys-devel/gcc[hardened].

So who overrides it in `CFLAGS` with `-D_FORTIFY_SOURCE=2`?  The package, in src/CMakeLists.txt and cmake/modules/DefineCompilerFlags.cmake.  Their changelog mentions a fix for distributions defining it to >2, but that doesn’t work with Gentoo, as we don’t do it in `CFLAGS`.

Cf.:
https://github.com/nextcloud/desktop/pull/4703
https://github.com/nextcloud/desktop/issues/4697 (contains workaround patch)
https://bugzilla.opensuse.org/show_bug.cgi?id=1201070
Comment 9 Bernard Cafarelli gentoo-dev 2023-02-10 17:37:54 UTC
Thanks Thomas, I had not seen the first line that it was a hardened profile!
Coincidentally, a fix for this was pushed this week in ~arch version (will stabilize after a few days), marking as duplicate of that one!

*** This bug has been marked as a duplicate of bug 890072 ***
Comment 10 Thomas Schneider 2023-02-10 17:38:39 UTC
Created attachment 850362 [details, diff]
remove -D_FORTIFY_SOURCE override completely

(In reply to Thomas Schneider from comment #8)
> https://github.com/nextcloud/desktop/issues/4697 (contains workaround patch)

Turns out this doesn’t apply with the current version, so here’s an updated patch for that one.  Should probably fixed upstream by correctly checking the macro, and the patch should be included in Gentoo only if it’s guaranteed we set at least _FORTIFY_SOURCE=2.
Comment 11 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-02-11 00:04:16 UTC
(In reply to Thomas Schneider from comment #10)
> Created attachment 850362 [details, diff] [details, diff]
> remove -D_FORTIFY_SOURCE override completely
> 
> (In reply to Thomas Schneider from comment #8)
> > https://github.com/nextcloud/desktop/issues/4697 (contains workaround patch)
> 
> Turns out this doesn’t apply with the current version, so here’s an updated
> patch for that one.  Should probably fixed upstream by correctly checking
> the macro, and the patch should be included in Gentoo only if it’s
> guaranteed we set at least _FORTIFY_SOURCE=2.

Isn't this fixed by what we did in bug 890072? And yes, it is guaranteed.