aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2018-02-14 11:50:23 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2018-02-14 11:50:23 +0200
commitedc9022131b77cec3fe5a662766e36fa9a71d23e (patch)
tree1e084ffcf7ec3da9ad1eb2e6755335bdda9137f8
parent5d615c7ae1761d1511e01d0b4bea4920fda190a7 (diff)
Enable modules support only for VC 15u5 and up, drop hacks for earlier
-rw-r--r--build2/cc/compile-rule.cxx34
-rw-r--r--build2/cc/parser.cxx15
-rw-r--r--build2/cc/parser.hxx1
-rw-r--r--build2/cxx/init.cxx6
-rw-r--r--tests/cc/modules/testscript58
5 files changed, 20 insertions, 94 deletions
diff --git a/build2/cc/compile-rule.cxx b/build2/cc/compile-rule.cxx
index e77ef08..1e1d45d 100644
--- a/build2/cc/compile-rule.cxx
+++ b/build2/cc/compile-rule.cxx
@@ -2991,41 +2991,15 @@ namespace build2
if (ps)
psrc.active = true; // Re-arm.
- // Prior to 15u5 VC was not using the 'export module' syntax so we
- // use the preprequisite type to distinguish between interface and
- // implementation units.
+ // Prior to 15u5 (19.12) VC was not using the 'export module M;'
+ // syntax so we use the preprequisite type to distinguish between
+ // interface and implementation units.
//
if (cid == compiler_id::msvc &&
cmaj == 19 && cmin <= 11 &&
x_mod != nullptr && src.is_a (*x_mod))
{
- // It's quite painful to guard the export with an #if/#endif so
- // if it is present, "fixup" the (temporary) preprocessed output
- // by getting rid of the keyword.
- //
- // Note: when removing this also remember to remove the test.
- //
- if (tu.mod.iface)
- {
- // We can only fixup a temporary file.
- //
- if (!ps)
- fail (relative (src)) << "fixup requires preprocessor";
-
- // Stomp out the export keyword with spaces. We are using
- // std::fstream since our fdstream does not yet support
- // seeking.
- //
- fstream os (psrc.path.string (), fstream::out | fstream::in);
- auto pos (static_cast<fstream::pos_type> (p.export_pos));
-
- if (!os.is_open () ||
- !os.seekp (pos) ||
- !os.write (" ", 6))
- fail << "unable to overwrite preprocessor output";
- }
- else
- tu.mod.iface = true;
+ tu.mod.iface = true;
}
return pair<translation_unit, string> (move (tu), p.checksum);
diff --git a/build2/cc/parser.cxx b/build2/cc/parser.cxx
index fcb6265..c8fcf4b 100644
--- a/build2/cc/parser.cxx
+++ b/build2/cc/parser.cxx
@@ -82,23 +82,14 @@ namespace build2
}
else if (id == "export")
{
- uint64_t pos (t.position);
-
switch (l_->next (t))
{
case type::lcbrace: ++bb; ex = true; break;
case type::identifier:
{
- if (id == "module")
- {
- export_pos = pos;
- parse_module (t, true);
- }
- else if (id == "import")
- parse_import (t, true);
- else
- n = false; // Something else (e.g., export namespace).
-
+ if (id == "module") parse_module (t, true);
+ else if (id == "import") parse_import (t, true);
+ else n = false; // Something else (e.g., export namespace).
break;
}
default: n = false; break;
diff --git a/build2/cc/parser.hxx b/build2/cc/parser.hxx
index bec67bd..a4fd5f8 100644
--- a/build2/cc/parser.hxx
+++ b/build2/cc/parser.hxx
@@ -39,7 +39,6 @@ namespace build2
public:
string checksum; // Translation unit checksum.
- uint64_t export_pos; // Temporary hack, see parse_unit().
private:
lexer* l_;
diff --git a/build2/cxx/init.cxx b/build2/cxx/init.cxx
index ff97f5b..826d2b0 100644
--- a/build2/cxx/init.cxx
+++ b/build2/cxx/init.cxx
@@ -163,10 +163,10 @@ namespace build2
// While modules are supported in VC15u0 (19.10), there is a
// bug in separate interface/implementation unit support which
// makes them pretty much unusable. This has been fixed in
- // VC15u3 (19.11). And VC15u5 supports the 'export module M;'
- // syntax.
+ // VC15u3 (19.11). And VC15u5 (19.12) supports the 'export
+ // module M;' syntax.
//
- if (mj > 19 || (mj == 19 && mi >= (l ? 10 : 11)))
+ if (mj > 19 || (mj == 19 && mi >= (l ? 10 : 12)))
{
r.push_back (
mj > 19 || mi > 11
diff --git a/tests/cc/modules/testscript b/tests/cc/modules/testscript
index a2b057d..ac46451 100644
--- a/tests/cc/modules/testscript
+++ b/tests/cc/modules/testscript
@@ -22,10 +22,10 @@ cxx.features.modules = true
using cxx
-# We forced modules but for VC we need at least 15u3 (19.11). So "unforce"
+# We forced modules but for VC we need at least 15u5 (19.12). So "unforce"
# them in this case.
#
-if ($cxx.id == 'msvc' && $cxx.version.major == 19 && $cxx.version.minor < 11)
+if ($cxx.id == 'msvc' && $cxx.version.major == 19 && $cxx.version.minor < 12)
cxx.features.modules = false
hxx{*}: extension = hxx
@@ -53,11 +53,7 @@ EOI
# define LIBFOO_EXPORT
#endif
-#if __cpp_modules >= 201704
-export
-#endif
-module foo.core;
-
+export module foo.core;
export LIBFOO_EXPORT int f (int);
EOI
@@ -123,10 +119,7 @@ $* test clean <<EOI
# "Bad" match which we should better.
#
+cat <<EOI >=core.mxx
- #if __cpp_modules >= 201704
- export
- #endif
- module bar.core;
+ export module bar.core;
EOI
: separator
@@ -202,11 +195,7 @@ $* test clean <<EOI
:
{
+cat <<EOI >=base.mxx
- #if __cpp_modules >= 201704
- export
- #endif
- module foo.base;
-
+ export module foo.base;
export import foo.core;
EOI
@@ -215,10 +204,7 @@ $* test clean <<EOI
# define LIBFOO_EXPORT
#endif
- #if __cpp_modules >= 201704
- export
- #endif
- module foo.extra;
+ export module foo.extra;
export
{
@@ -231,10 +217,7 @@ $* test clean <<EOI
EOI
+cat <<EOI >=foo.mxx
- #if __cpp_modules >= 201704
- export
- #endif
- module foo;
+ export module foo;
export
{
@@ -290,8 +273,6 @@ $* test clean <<EOI
: entire, recursively-explored list of BMIs.
:
{
- # Note: using VC export module fixup support.
-
+cat <<EOI >=base.mxx
export module foo.base;
import foo.core;
@@ -329,10 +310,7 @@ $* test clean <<EOI
:
ln -s ../core.mxx ../core.cxx ../driver.cxx ./;
cat <<EOI >=foo-core.mxx;
- #if __cpp_modules >= 201704
- export
- #endif
- module foo.core;
+ export module foo.core;
export inline int f (int i) {return i - 2;}
EOI
$* update <<EOI;
@@ -359,10 +337,7 @@ $* test clean <<EOI
: Test the __symexport feature.
:
cat <<EOI >=core.mxx;
- #if __cpp_modules >= 201704
- export
- #endif
- module foo.core;
+ export module foo.core;
export __symexport int f (int);
@@ -381,18 +356,5 @@ cat <<EOI >=driver.cxx;
$* test clean <<EOI
./: lib{foo} exe{test} # Full build.
exe{test}: cxx{driver} lib{foo}
- lib{foo}: mxx{core} cxx{core-f} # core-g @@ VC
- EOI
-
-: export-fixup
-:
-: Test removing the export keyword for VC compatibility.
-:
-ln -s ../core.cxx ../driver.cxx ./;
-cat <<EOI >=core.mxx;
- export module foo.core;
- export int f (int);
+ lib{foo}: mxx{core} cxx{core-f} # @@ VC: core-g
EOI
-$* test <'exe{test}: cxx{driver core} mxx{core}';
-touch core.mxx; # Test use of cached .ii's.
-$* test clean <'exe{test}: cxx{driver core} mxx{core}'