lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <44d1a208-684a-4c68-a4a6-41d906e87585@linux.dev>
Date: Sat, 27 Jul 2024 21:27:02 -0700
From: Yonghong Song <yonghong.song@...ux.dev>
To: Stanislav Fomichev <sdf@...ichev.me>, Jakub Kicinski <kuba@...nel.org>
Cc: Andrii Nakryiko <andrii.nakryiko@...il.com>, bpf@...r.kernel.org,
 netdev@...r.kernel.org, ast@...nel.org, daniel@...earbox.net,
 andrii@...nel.org, martin.lau@...ux.dev, song@...nel.org, yhs@...com,
 john.fastabend@...il.com, kpsingh@...nel.org, haoluo@...gle.com,
 jolsa@...nel.org
Subject: Re: [PATCH bpf] selftests/bpf: Filter out _GNU_SOURCE when compiling
 test_cpp


On 7/26/24 8:32 PM, Stanislav Fomichev wrote:
> On 07/26, Jakub Kicinski wrote:
>> On Fri, 26 Jul 2024 17:45:06 -0700 Andrii Nakryiko wrote:
>>> or we could
>>>
>>> #ifndef _GNU_SOURCE
>>> #define _GNU_SOURCE
>>> #endif
>>>
>>> (though we have 61 places with that...) so as to not have to update
>>> every target in Makefile.
>> AFAIU we have -D_GNU_SOURCE= twice _in the command line args_ :(
>> One is from the Makefile which now always adds it to CFLAGS,
>> the other is "built-in" in g++ for some weird reason.
>>
>> FWIW I have added this patch to the netdev "hack queue" so no
>> preference any more where the patch lands :)
> Yeah, it can't be fixed with an ifdef because the conflict happens a bit
> earlier:
>
> $ echo "int main(int argc, char *argv[]){return 0;}" > test.cpp
> $ clang++ -Wall -Werror -D_GNU_SOURCE= test.cpp
> In file included from <built-in>:454:
> <command line>:1:9: error: '_GNU_SOURCE' macro redefined [-Werror,-Wmacro-redefined]
>      1 | #define _GNU_SOURCE
>        |         ^
> <built-in>:445:9: note: previous definition is here
>    445 | #define _GNU_SOURCE 1
>        |         ^

The above _GNU_SOURCE definition is defined by clang itself in the very beginning
of compilation.
See https://github.com/llvm/llvm-project/blob/main/clang/lib/Basic/Targets/OSTargets.h

// Linux target
template <typename Target>
class LLVM_LIBRARY_VISIBILITY LinuxTargetInfo : public OSTargetInfo<Target> {
protected:
   void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
                     MacroBuilder &Builder) const override {
     // Linux defines; list based off of gcc output
     DefineStd(Builder, "unix", Opts);
     DefineStd(Builder, "linux", Opts);
     if (Triple.isAndroid()) {
       Builder.defineMacro("__ANDROID__", "1");
       this->PlatformName = "android";
       this->PlatformMinVersion = Triple.getEnvironmentVersion();
       const unsigned Maj = this->PlatformMinVersion.getMajor();
       if (Maj) {
         Builder.defineMacro("__ANDROID_MIN_SDK_VERSION__", Twine(Maj));
         // This historical but ambiguous name for the minSdkVersion macro. Keep
         // defined for compatibility.
         Builder.defineMacro("__ANDROID_API__", "__ANDROID_MIN_SDK_VERSION__");
       }
     } else {
         Builder.defineMacro("__gnu_linux__");
     }
     if (Opts.POSIXThreads)
       Builder.defineMacro("_REENTRANT");
     if (Opts.CPlusPlus)
       Builder.defineMacro("_GNU_SOURCE");
     if (this->HasFloat128)
       Builder.defineMacro("__FLOAT128__");
   }
...

This caused a conflict with -D_GNU_SOURCE= and hence compilation failure.

> 1 error generated.


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ