Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MinGW build of verilator 3.872 breaks on setenv() #929

Closed
veripoolbot opened this issue Jun 8, 2015 · 3 comments
Closed

MinGW build of verilator 3.872 breaks on setenv() #929

veripoolbot opened this issue Jun 8, 2015 · 3 comments
Assignees
Labels
area: configure/compiling Issue involves configuring or compilating Verilator itself resolution: fixed Closed; fixed

Comments

@veripoolbot
Copy link
Contributor


Author Name: Hans Tichelaar
Original Redmine Issue: 929 from https://www.veripool.org
Original Date: 2015-06-08
Original Assignee: Wilson Snyder (@wsnyder)


When building verilator 3.872 with MinGW I get following error:

@../V3Os.cpp: In static member function 'static void V3Os::setenvStr(const string
&, const string&, const string&)':
../V3Os.cpp:59:45: error: 'setenv' was not declared in this scope
setenv(envvar.c_str(),value.c_str(),true);@

The error is caused by the fact that MinGW doesn't support setenv() and the compiler flags are insufficient to switch to the putenv() alternative. The code that causes this issue is in file V3Os.cpp, lines 58 - 65:

#if defined(_BSD_SOURCE) || (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112L)
     setenv(envvar.c_str(),value.c_str(),true);
#else
     //setenv() replaced by putenv() in MinGW/Solaris environment. Prototype is different
     //putenv() requires NAME=VALUE format
     string vareq = envvar + "=" + value;
     putenv(const_cast<char*>(vareq.c_str()));
#endif

Simple workaround can be following:

#if !defined(__MINGW32__) && (defined(_BSD_SOURCE) || (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112L))
     setenv(envvar.c_str(),value.c_str(),true);
#else
     //setenv() replaced by putenv() in MinGW/Solaris environment. Prototype is different
     //putenv() requires NAME=VALUE format
     string vareq = envvar + "=" + value;
     putenv(const_cast<char*>(vareq.c_str()));
#endif

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Hans Tichelaar
Original Date: 2015-06-08T09:55:49Z


The redmine webtool seems to have problems with double underlines. It should be MINGW32 (double underline MINGW32 double underline).

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2015-06-08T11:24:09Z


Thanks for the patch, pushed to git towards 3.875.

BTW use <pre> and </pre> to appease the wiki.

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2015-08-13T01:44:10Z


In 3.876.

@veripoolbot veripoolbot added area: configure/compiling Issue involves configuring or compilating Verilator itself resolution: fixed Closed; fixed labels Dec 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: configure/compiling Issue involves configuring or compilating Verilator itself resolution: fixed Closed; fixed
Projects
None yet
Development

No branches or pull requests

2 participants