Skip to content

Commit

Permalink
ptx bison: fix compilation on linux
Browse files Browse the repository at this point in the history
  • Loading branch information
romnn committed Apr 23, 2024
1 parent 6e40940 commit ba3f3e4
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 6 deletions.
15 changes: 11 additions & 4 deletions ptx/bison/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ fn output_path() -> PathBuf {
.unwrap()
}

fn target_os() -> Option<String> {
std::env::var("CARGO_CFG_TARGET_OS").ok()
}

#[must_use]
fn is_debug() -> bool {
match std::env::var("PROFILE").unwrap().as_str() {
Expand Down Expand Up @@ -248,10 +252,13 @@ fn build_ptx_parser() -> eyre::Result<()> {
.static_flag(true)
.warnings(false)
.flag("-Wno-everything")
.flag("-std=c++14")
.flag("-mmacosx-version-min=10.15")
.include(source_dir)
.files(sources);
.flag("-std=c++14");

if target_os().as_deref() == Some("macos") {
// TODO: query sw_vers to get macos version
build.flag("-mmacosx-version-min=10.15");
}
build.include(out_dir).include(source_dir).files(sources);

enable_diagnostics_color(&mut build);
configure_debug_mode(&mut build);
Expand Down
2 changes: 1 addition & 1 deletion ptx/bison/src/core.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include <cassert>
#include <cstddef>
#include <cstdlib>

#include "hal.hpp"

Expand Down
2 changes: 1 addition & 1 deletion ptx/bison/src/gpgpu.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include <cstdlib>
#include <cassert>
#include <map>
#include <set>
#include <string>
Expand Down
3 changes: 3 additions & 0 deletions ptx/bison/src/gpgpu_context.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#include "gpgpu_context.hpp"

#ifndef __APPLE__
#include <sstream>
#endif
#include <unistd.h>

#include "ptx.parser.tab.h"
Expand Down
2 changes: 2 additions & 0 deletions ptx/bison/src/ptx_instruction.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "ptx_instruction.hpp"

#include <algorithm>

#include "function_info.hpp"
#include "hal.hpp"
#include "ptx.parser.tab.h"
Expand Down
2 changes: 2 additions & 0 deletions ptx/bison/src/ptx_recognizer.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "ptx_recognizer.hpp"

#include <cstdarg>

#include "function_info.hpp"
#include "gpgpu_context.hpp"
#include "opcodes.h"
Expand Down

0 comments on commit ba3f3e4

Please sign in to comment.