[PATCH] add default "/usr/bin:/bin" after $PATH

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] add default "/usr/bin:/bin" after $PATH

Sourceware - systemtap mailing list
my use case is like this, I install gcc-4.8.5 and devtoolset-9-gcc,
while I set the PATH by "source /opt/rh/devtoolset-9/enable" to use
gcc-9, but when I use "stap test.stap", I always get compile errors
for "gcc: error: unrecognized command line option
‘-fpatchable-function-entry=2’", the option
‘-fpatchable-function-entry=2’ is not supported by gcc-4.8.5 but
supported by gcc-9.
The stap process building always use gcc-4.8.5 from /usr/bin not from
the first path of PATH.
As I think the default /usr/bin:/bin should be added after $PATH.

Signed-off-by: Chunmei Xu <[hidden email]>
---
 buildrun.cxx | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/buildrun.cxx b/buildrun.cxx
index 12abe78..371da96 100644
--- a/buildrun.cxx
+++ b/buildrun.cxx
@@ -95,13 +95,14 @@ run_make_cmd(systemtap_session& s, vector<string>& make_cmd,
 static vector<string>
 make_any_make_cmd(systemtap_session& s, const string& dir, const string& target)
 {
-  string newpath("PATH=/usr/bin:/bin");
+  string newpath("PATH=");
   const char *oldpath = getenv("PATH");
   if (oldpath != NULL)
     {
-      newpath += ':';
       newpath += oldpath;
+      newpath += ':';
     }
+  newpath += "/usr/bin:/bin";
 
   vector<string> make_cmd
     {
--
1.8.3.1

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] add default "/usr/bin:/bin" after $PATH

Sourceware - systemtap mailing list
I submit a bug at: https://sourceware.org/bugzilla/show_bug.cgi?id=25994

在 2020/5/15 下午2:28, Chunmei Xu 写道:

> my use case is like this, I install gcc-4.8.5 and devtoolset-9-gcc,
> while I set the PATH by "source /opt/rh/devtoolset-9/enable" to use
> gcc-9, but when I use "stap test.stap", I always get compile errors
> for "gcc: error: unrecognized command line option
> ‘-fpatchable-function-entry=2’", the option
> ‘-fpatchable-function-entry=2’ is not supported by gcc-4.8.5 but
> supported by gcc-9.
> The stap process building always use gcc-4.8.5 from /usr/bin not from
> the first path of PATH.
> As I think the default /usr/bin:/bin should be added after $PATH.
>
> Signed-off-by: Chunmei Xu <[hidden email]>
> ---
>   buildrun.cxx | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/buildrun.cxx b/buildrun.cxx
> index 12abe78..371da96 100644
> --- a/buildrun.cxx
> +++ b/buildrun.cxx
> @@ -95,13 +95,14 @@ run_make_cmd(systemtap_session& s, vector<string>& make_cmd,
>   static vector<string>
>   make_any_make_cmd(systemtap_session& s, const string& dir, const string& target)
>   {
> -  string newpath("PATH=/usr/bin:/bin");
> +  string newpath("PATH=");
>     const char *oldpath = getenv("PATH");
>     if (oldpath != NULL)
>       {
> -      newpath += ':';
>         newpath += oldpath;
> +      newpath += ':';
>       }
> +  newpath += "/usr/bin:/bin";
>  
>     vector<string> make_cmd
>       {