mirror of
				https://github.com/YosysHQ/yosys
				synced 2025-11-04 05:19:11 +00:00 
			
		
		
		
	Make all compile under OpenBSD (#3423)
Co-authored-by: Josuah Demangeon <me@josuah.net>
This commit is contained in:
		
							parent
							
								
									bc012995b4
								
							
						
					
					
						commit
						29a5947bf8
					
				
					 3 changed files with 50 additions and 3 deletions
				
			
		
							
								
								
									
										11
									
								
								Makefile
									
										
									
									
									
								
							
							
						
						
									
										11
									
								
								Makefile
									
										
									
									
									
								
							| 
						 | 
					@ -155,7 +155,7 @@ bumpversion:
 | 
				
			||||||
# is just a symlink to your actual ABC working directory, as 'make mrproper'
 | 
					# is just a symlink to your actual ABC working directory, as 'make mrproper'
 | 
				
			||||||
# will remove the 'abc' directory and you do not want to accidentally
 | 
					# will remove the 'abc' directory and you do not want to accidentally
 | 
				
			||||||
# delete your work on ABC..
 | 
					# delete your work on ABC..
 | 
				
			||||||
ABCREV = 4e89fc7
 | 
					ABCREV = 7cc11f7
 | 
				
			||||||
ABCPULL = 1
 | 
					ABCPULL = 1
 | 
				
			||||||
ABCURL ?= https://github.com/YosysHQ/abc
 | 
					ABCURL ?= https://github.com/YosysHQ/abc
 | 
				
			||||||
ABCMKARGS = CC="$(CXX)" CXX="$(CXX)" ABC_USE_LIBSTDCXX=1 ABC_USE_NAMESPACE=abc VERBOSE=$(Q)
 | 
					ABCMKARGS = CC="$(CXX)" CXX="$(CXX)" ABC_USE_LIBSTDCXX=1 ABC_USE_NAMESPACE=abc VERBOSE=$(Q)
 | 
				
			||||||
| 
						 | 
					@ -199,11 +199,16 @@ endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
endif
 | 
					endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					ABC_ARCHFLAGS = ""
 | 
				
			||||||
 | 
					ifeq ($(OS), OpenBSD)
 | 
				
			||||||
 | 
					ABC_ARCHFLAGS += "-DABC_NO_RLIMIT"
 | 
				
			||||||
 | 
					endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ifeq ($(CONFIG),clang)
 | 
					ifeq ($(CONFIG),clang)
 | 
				
			||||||
CXX = clang
 | 
					CXX = clang
 | 
				
			||||||
LD = clang++
 | 
					LD = clang++
 | 
				
			||||||
CXXFLAGS += -std=$(CXXSTD) -Os
 | 
					CXXFLAGS += -std=$(CXXSTD) -Os
 | 
				
			||||||
ABCMKARGS += ARCHFLAGS="-DABC_USE_STDINT_H -Wno-c++11-narrowing"
 | 
					ABCMKARGS += ARCHFLAGS="-DABC_USE_STDINT_H -Wno-c++11-narrowing $(ABC_ARCHFLAGS)"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ifneq ($(SANITIZER),)
 | 
					ifneq ($(SANITIZER),)
 | 
				
			||||||
$(info [Clang Sanitizer] $(SANITIZER))
 | 
					$(info [Clang Sanitizer] $(SANITIZER))
 | 
				
			||||||
| 
						 | 
					@ -226,7 +231,7 @@ else ifeq ($(CONFIG),gcc)
 | 
				
			||||||
CXX = gcc
 | 
					CXX = gcc
 | 
				
			||||||
LD = gcc
 | 
					LD = gcc
 | 
				
			||||||
CXXFLAGS += -std=$(CXXSTD) -Os
 | 
					CXXFLAGS += -std=$(CXXSTD) -Os
 | 
				
			||||||
ABCMKARGS += ARCHFLAGS="-DABC_USE_STDINT_H"
 | 
					ABCMKARGS += ARCHFLAGS="-DABC_USE_STDINT_H $(ABC_ARCHFLAGS)"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
else ifeq ($(CONFIG),gcc-static)
 | 
					else ifeq ($(CONFIG),gcc-static)
 | 
				
			||||||
LD = $(CXX)
 | 
					LD = $(CXX)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -192,6 +192,13 @@ void yosys_atexit()
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if defined(__OpenBSD__)
 | 
				
			||||||
 | 
					namespace Yosys {
 | 
				
			||||||
 | 
					extern char *yosys_argv0;
 | 
				
			||||||
 | 
					extern char yosys_path[PATH_MAX];
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int main(int argc, char **argv)
 | 
					int main(int argc, char **argv)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	std::string frontend_command = "auto";
 | 
						std::string frontend_command = "auto";
 | 
				
			||||||
| 
						 | 
					@ -498,6 +505,12 @@ int main(int argc, char **argv)
 | 
				
			||||||
	if (print_stats)
 | 
						if (print_stats)
 | 
				
			||||||
		log_hasher = new SHA1;
 | 
							log_hasher = new SHA1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if defined(__OpenBSD__)
 | 
				
			||||||
 | 
						// save the executable origin for proc_self_dirname()
 | 
				
			||||||
 | 
						yosys_argv0 = argv[0];
 | 
				
			||||||
 | 
						realpath(yosys_argv0, yosys_path);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if defined(__linux__)
 | 
					#if defined(__linux__)
 | 
				
			||||||
	// set stack size to >= 128 MB
 | 
						// set stack size to >= 128 MB
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -871,6 +871,35 @@ std::string proc_self_dirname()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	return "/";
 | 
						return "/";
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					#elif defined(__OpenBSD__)
 | 
				
			||||||
 | 
					char yosys_path[PATH_MAX];
 | 
				
			||||||
 | 
					char *yosys_argv0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					std::string proc_self_dirname(void)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						char buf[PATH_MAX + 1] = "", *path, *p;
 | 
				
			||||||
 | 
						// if case argv[0] contains a valid path, return it
 | 
				
			||||||
 | 
						if (strlen(yosys_path) > 0) {
 | 
				
			||||||
 | 
							p = strrchr(yosys_path, '/');
 | 
				
			||||||
 | 
							snprintf(buf, sizeof buf, "%*s/", (int)(yosys_path - p), yosys_path);
 | 
				
			||||||
 | 
							return buf;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						// if argv[0] does not, reconstruct the path out of $PATH
 | 
				
			||||||
 | 
						path = strdup(getenv("PATH"));
 | 
				
			||||||
 | 
						if (!path)
 | 
				
			||||||
 | 
							log_error("getenv(\"PATH\") failed: %s\n",  strerror(errno));
 | 
				
			||||||
 | 
						for (p = strtok(path, ":"); p; p = strtok(NULL, ":")) {
 | 
				
			||||||
 | 
							snprintf(buf, sizeof buf, "%s/%s", p, yosys_argv0);
 | 
				
			||||||
 | 
							if (access(buf, X_OK) == 0) {
 | 
				
			||||||
 | 
								*(strrchr(buf, '/') + 1) = '\0';
 | 
				
			||||||
 | 
								free(path);
 | 
				
			||||||
 | 
								return buf;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						free(path);
 | 
				
			||||||
 | 
						log_error("Can't determine yosys executable path\n.");
 | 
				
			||||||
 | 
						return NULL;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
	#error "Don't know how to determine process executable base path!"
 | 
						#error "Don't know how to determine process executable base path!"
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue